Problem with mkdir in build script

After building I need to copy some files around. This has worked nicely so far. One step, however, doesn’t work anymore even though I haven’t changed anything.

I’ve copied a script that works okay in Terminal:

dim cmd as string = "mkdir /Users/beatrixwillius/Documents/\\ Datei/Development/Mail\\ Archiver/code\\ current/Builds\\ -\\ max.rbp/final" dim theOutput as string = doShellCommand(cmd) print theOutput

This creates an empty file and then there is an error message: File exists.

Some lines of code before I create another directory with

"mkdir " + CurrentBuildLocation + “/Extras”

and this works okay. So I really don’t understand why the first script doesn’t.

Xojo 2013r3, Mac OS 10.9

It’s likely that the “final” directory doesn’t get deleted between builds. Are you removing the directory before trying to create it again?

Nope, that’s not the problem, because in this case the error message would be “directory exists” or something like that. I delete the “final” directory before trying the script. Also, I simply ignore the error for final use.

mkdir will only make a single folder - if you need to make a hierarchy of them, you can use the “-p” option. Could that be it?

Nope, that’s not the problem either. The build directory of Mail Archiver exists because the app has just been built.

Tomorrow I’m going to try an AppleScript via the shell.

Another stab in the dark: do you really have a leading space in the folder named " Datei" ?

Do you still have “Use Builds folder” checked? If not, the folder is there but gets deleted at the end, maybe that’s the issue?

Also, have you tried to copy this command and paste it into Terminal? Does that work? Could be that the folder is write protected. Or maybe Xojo now secretly creates a “final” file itself. Have you tried it with another name?

Yes, there really is a space in Datei. The terminal command works, which makes it so puzzling. The script itself worked for the last years (2 - 3???).

I think that Thomas nailed it: “final” must be a reserved word now. Trying with

dim cmd as string = “mkdir /Users/beatrixwillius/Documents/\ Datei/Development/Mail\ Archiver/code\ current/Builds\ -\ max.rbp/smoerebroed”

works fine. Grr…

We had the same problem in one of our Web Apps, so I changed it to use currentDirectory and f.createFolder instead.

[quote=53171:@Beatrix Willius]
I think that Thomas nailed it: “final” must be a reserved word now. Trying with

dim cmd as string = “mkdir /Users/beatrixwillius/Documents/\ Datei/Development/Mail\ Archiver/code\ current/Builds\ -\ max.rbp/smoerebroed”

works fine. Grr…[/quote]
Wouldn’t matter if Xojo reserved FINAL since your not asking Xojo to run that code so it’s reserved words don’t matter
There’s got to be something else

@Norman: but what else can it be??? The exact same code works if I change from “final” to “smoerebroed”. I’m now using an AppleScript.

dim cmd as String = "/usr/bin/osascript -e 'tell application ""Finder"" to make new folder at ""Macci:Users:beatrixwillius:Documents: Datei:Development:Mail Archiver:code current:Builds - max.rbp"" with properties {name:""final""}'" dim theOutput as string = doShellCommand(cmd)

Not yet 100% where I want it, but at least the folder is created.

@David: I never had thought that createFolder works in a script. Thanks for the tip!

No idea but its not a Xojo issue since mkdir is not something Xojo is executing

I’d do a “run paused” then go into terminal & issue those same commands and see what happens since that will be more similar to what the IDE would do (not quite exactly the same but closer)

mkdir should maybe be written as “/bin/mkdir” but I’d expect some other error to be reported

Try adding a -p to the mkdir command and escaping the hyphen in the build folder name:

mkdir -p /Users/beatrixwillius/Documents/\\ Datei/Development/Mail\\ Archiver/code\\ current/Builds\\ \\-\\ max.rbp/final

Here is a routine I have to make a folder (with sub folders) that works for both Mac & Windows:

Function MakeFolder(Txt as String, Unique as Boolean = False) As FolderItem
  Txt = Txt.Replaceall(Sep + Sep,Sep)
  if Unique then
    dim f as FolderItem = GetFolderItem(Txt,FolderItem.PathTypeAbsolute)
    if f <> nil then
      dim ct as integer = 0
      if txt.Right(1) = sep then txt = txt.left(txt.len-1)
      while f.Exists
        ct = ct +1
        f = GetFolderItem(Txt + "_" + str(ct),FolderItem.PathTypeAbsolute)
      wend
      Txt = f.absolutepath
    end if
  end if
  Dim Results as FolderItem
  Dim Sh as new Shell
  Dim S as string
  if TargetMacOS then
    s = "mkdir -p " + chr(34) + "/Volumes/" + replaceall(Txt,":","/") + chr(34)
  else
    if TargetWin32 then
      S = "mkdir " + chr(34) + Txt + chr(34)
    else
      msgbox("Platform Not Supported.")
    end if
  end if
  Sh.Execute(S)
  Results = GetFolderItem(Txt,FolderItem.PathTypeAbsolute)
  Return Results
End Function

This works exceptionally well for me. I am sure this code could be adapted for other platforms as well, but all I need are Windows & Mac.

@ Christopher Wade
You have in your code the following line:

Txt = Txt.Replaceall(Sep + Sep,Sep)

I know what it does, but where do you define/fill Sep?