Slash Bug

Hi! This is a bug that I’ve always encountered since I started using Scrivener, but it wasn’t consistent, so I wrote it off as a random weirdness. However, lately it keeps occurring (both with 1.0 and with most recent beta 1.09) so I thought I would report it.

Steps to reproduce:

Go to File -> New Project and input as Project Name:

[this is a test] [this is a test/this is a test] this is a test

This will get you two results, either:

a) Scrivener refuses to create a project with this name, saying that:

or, more interestingly:

b) Scrivener creates a folder named:

[this is a test] [this is a test

with this file inside:

this is a test] this is a test.scriv

I can create files with that name/pattern in TextEdit without problems, so I don’t think it’s a Cocoa bug; no error message appears in the Console. This happens to me in various, different folders (e.g. not a FileVault problem, since it also happens on external USB or Firewire hard drives) and in some folders only result a) happens, while in others I get a) or b) randomly.

I run MacOS 10.4.10 on PowerPC G4, if that helps.

I don’t think the behavior should be undefined, but I don’t think Scrivener (or any application) should allow you to create a filename with a slash in it. It’s just asking for trouble. Open one, maybe.

Yeah, the bug is that it lets you type in a slash. This character is reserved for defining folder hierarchies by the system (for example, “/Applications/Utilities” is how you would access the Utilities folder in Applications, using the underlying system). I am guessing this is why you get data inside the project because it is actually putting everything after the slash into the folder that gets created for your project bundle. Weird that it does that! But I guess that is what is happening. While TextEdit might go ahead and let you do this, having slashes in a file name may cause problems in other applications, especially those that rely upon scripting.

Slashes should probably just either get a user warning, or silently converted to ‘_’ which is how I’ve seen other applications handle them. Another character you should avoid is the colon. Though deprecated, this used to be how folder hierarchies were defined before OS X (“Macintosh HD:System:Preferences”, for example). It might not cause any problems with a Cocoa application like Scrivener (not sure about that), but I have seen it cause conflicts in Carbon based applications that are using certain toolkits. So it is good idea to avoid it.

mamster and AmberV have hit the nail on the head - you shouldn’t use slashes in your file names. Scrivener should not allow it, either, so I’ll look into the best way of preventing it.
Best,
Keith

I do know that slashes are used for paths, but have you tried creating folders with a slash in their name, e.g: test/test? It works perfectly, since OSX just converts them (if you drag and drop a folder with such a name in Terminal, Terminal just reads it as: /Volumes/volume\ name/test:test/).

IMHO, since OSX handles it just fine, Scrivener should as well, especially since it’s a fantastic Cocoa application. Imposing a limitation that OSX doesn’t have seems just weird to me. But that’s just my two cents, I bow to the creator’s wishes. After all, it’s just the hassle of giving the file a different name when I create it and then renaming it to what I want.

The point is that clearly Cocoa doesn’t handle it fine. Scrivener is doing nothing weird here; Scrivener just uses the standard Cocoa methods for creating the file. But the file system as used by Cocoa doesn’t like the slash in the name… So Scrivener will have to avoid it. Annoyingly, having researched this now, there are no Cocoa methods for checking if a file name is valid or for converting a file name to something that is definitely valid. So, given the problems this can cause, it is much better that Scrivener disallows such characters in file names.
Best,
Keith

HFS is not deprecated, as far as I know. File dialog boxes are using the HFS path name convention, as does the Finder. I thought rather that it the case that POSIX and HFS are just two different ways of logical addressing of files that coexist in OS X.

I believe it is not a bug that it lets you type a “/”. As far as I know, this is a legal character in a file name in HFS. The POSIX representation of this character is “:”. The file dialog boxes represent file names using the HFS name, and so they convert “:” to “-” when they are typed to avoid your use of that character.

Happy Saturday.
–Bryce

See this Cocoa Builder thread for some of the difficulties involved:

cocoabuilder.com/archive/mes … /14/125706

Much easier just to disallow the use of problematic characters. :slight_smile:

Best,
Keith