-// wxLogDebug(*argv);
- wxString sCurrentFile;
-
- if(wxURI(*argv).IsReference())
- sCurrentFile = wxString(wxT("file://")) + *argv;
- else
- sCurrentFile = *argv;
-
- CFURLRef cfurlCurrentFile = CFURLCreateWithString(
- kCFAllocatorDefault,
- wxMacCFStringHolder(sCurrentFile, wxLocale::GetSystemEncoding()),
- NULL);
- wxASSERT(cfurlCurrentFile);
+ // Check for '<' as this will ring true for
+ // CFURLCreateWithString but is generally not considered
+ // typical on mac but is usually passed here from wxExecute
+ if (wxStrcmp(*argv, wxT("<")) == 0)
+ continue;
+
+
+ CFURLRef cfurlCurrentFile; // CFURL to hold file path
+ wxFileName argfn(*argv); // Filename for path
+
+ if(argfn.DirExists())
+ {
+ // First, try creating as a directory
+ cfurlCurrentFile = CFURLCreateWithFileSystemPath(
+ kCFAllocatorDefault,
+ wxMacCFStringHolder(*argv),
+ kDefaultPathStyle,
+ true); //true == directory
+ }
+ else if(argfn.FileExists())
+ {
+ // And if it isn't a directory try creating it
+ // as a regular file
+ cfurlCurrentFile = CFURLCreateWithFileSystemPath(
+ kCFAllocatorDefault,
+ wxMacCFStringHolder(*argv),
+ kDefaultPathStyle,
+ false); //false == regular file
+ }
+ else
+ {
+ // Argument did not refer to
+ // an entry in the local filesystem,
+ // so try creating it through CFURLCreateWithString
+ cfurlCurrentFile = CFURLCreateWithString(
+ kCFAllocatorDefault,
+ wxMacCFStringHolder(*argv),
+ NULL);
+ }