Hello all,
Know you why, when I copy an application with PB copyfile or copydirectory, copied application does not start?
While when I make it manually, it starts normally?
Best regards
[Solved] CopyFile() and CopyDirectory()
[Solved] CopyFile() and CopyDirectory()
Last edited by XaGau on Mon Apr 28, 2014 5:11 pm, edited 1 time in total.
Re: CopyFile() and CopyDirectory()
Did you compare the package contents of both?
macOS Catalina 10.15.7
Re: CopyFile() and CopyDirectory()
Hi XaGau. For OSX programs, the app file is actually a folder, so you'd need to copy the single app file with PureBasic's CopyDirectory() function. For example:XaGau wrote:...when I copy an application with PB copyfile or copydirectory, copied application does not start?
Code: Select all
CopyDirectory("/Applications/Calculator.app", "/Users/[username]/Calculator.app", "")
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel
Re: CopyFile() and CopyDirectory()
HI,
Thank you for replys.
I used CopyDirectory, and all the folders and files of the .app are copied, but the executable in \Contents\MacOS\ becomes a document
Best Regards
Thank you for replys.
I used CopyDirectory, and all the folders and files of the .app are copied, but the executable in \Contents\MacOS\ becomes a document
Best Regards
Re: CopyFile() and CopyDirectory()
You could try using CocoaMessage.
The NSFileManager class has a method named copyItemAtPath:toPath:error:
The NSFileManager class has a method named copyItemAtPath:toPath:error:
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: CopyFile() and CopyDirectory()
Hello again XaGau. After reading your last post, I took another look at it, and the results are quite strange. PureBasic's CopyDirectory() function does not seem to work stably with application files (.app). The copied applications work some of the time, and some of the time they are copied with zero bytes. I'm not quite sure what's causing this. I'm running PureBasic 5.20 LTS on OSX 10.8.XaGau wrote:I used CopyDirectory, and all the folders and files of the .app are copied, but the executable in \Contents\MacOS\ becomes a document
As a workaround, if you wouldn't mind using the API, you could use wilbert's suggestion:
Code: Select all
CocoaMessage(0, (CocoaMessage(0, 0, "NSFileManager defaultManager")), "copyItemAtPath:$", @"/Applications/Calculator.app", "toPath:$", @"/Users/[username]/Calc.app", "error:", #nil)
Code: Select all
NSFM = CocoaMessage(0, 0, "NSFileManager defaultManager")
sourceFile.s = "/Applications/Calculator.app"
destinationFile.s = "/Users/[username]/Calc.app"
CocoaMessage(0, NSFM, "copyItemAtPath:$", @sourceFile, "toPath:$", @destinationFile, "error:", #nil)
- The PureBasic Manual - CocoaMessage()
- Mac Developer Library - NSFileManager Class Reference
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel
Re: CopyFile() and CopyDirectory()
Hello all,
Thank you very much for your help, everything works well now.
Cordially
Thank you very much for your help, everything works well now.
Cordially
Re: [Solved] CopyFile() and CopyDirectory()
Old topic, but it seems CopyDirectory removes the executable permission of files when copying... seems wrong to me? That's why an .app won't start anymore after being copied with CopyDirectory.