filepath differences IDE vs standalone

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
slindstrom
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 29
Joined: Mon Apr 09, 2012 8:53 pm

filepath differences IDE vs standalone

Post by slindstrom » Sat Jan 21, 2017 1:59 am

It seems a lot has changed in LC 8.x. Possible these changes occurred earlier but here is my current issue.

I need the app to read and write to a couple of folders which will be inside the same folder as the app. This was all pretty simple in earlier versions of LC. I want the user to be able to place the app and the relevant folders inside whichever other folder the user chooses. So I check "the effective filename of this stack" and build my filepaths based on that. The problem is this. Running in the IDE, the resulting filepath is one thing but once saved as a standalone that filepath is different and no longer matches what the user sees in the Mac Finder. See how they differ below. The folders Contents and MacOS are, of course, invisible to the user.

How can I tweak my code so that it always finds folders nested in the same folder as the app regardless of whether it is running in the IDE or as a standalone? I suppose I could set itemDelimiter to "/" and delete any items that contain ".app" or "Contents" or "MacOS," from the filepath to the nested folder but this seems unnecessarily messy. ???
filepaths.jpg
Thanks in advance,

Sieg

PBH
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 129
Joined: Sun Feb 20, 2011 4:26 pm
Location: Vancouver Island, BC, Canada. ex.UK
Contact:

Re: filepath differences IDE vs standalone

Post by PBH » Sat Jan 21, 2017 4:34 am

I didn't understand what could have changed, because one (if not more) of my apps uses a similar reference, so I tested this in LC 5.5.5 and LC 8.1.3 (rc1) and they both gave exactly the same results as far as I can see, maybe we work differently.

Anyway, it's not too difficult to work the path back from the fileName and use a check for development or standalone to decide where to save the files, I personally don't think it's too messy, and it should be reliable, here's my take on it:

Code: Select all

on mouseUp
   put myAppFolder() into fld "myField"
end mouseUp

function myAppFolder
   put the effective fileName of this stack into tFolder
   set the itemDel to slash
   if the environment is "development" then
      delete the last item of tFolder
   else
      put the last item of tFolder & ".app" into tAppName
      delete item itemOffset(tAppName,tFolder) to -1 of tFolder
   end if
   return tFolder & "/"
end myAppFolder
Hope this helps.

Paul

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: filepath differences IDE vs standalone

Post by Klaus » Sat Jan 21, 2017 12:05 pm

Dag Sieg,

yep, that is a Mac specific thing, but therefore LC gave us -> specialfolderpath("resources") :D

In the IDE it will return the folder where the stack lies, so if you issue this command in stack "1-meet data"
put specialfolderpath("resources") you will get: /Applications/LiveCode

If usd in a standalone it will return the path to the folder inside of the app package where LC will put all
the files and folder you have added to the standalone via the "Copy files" tab in the standalone builder settings!
Know what I mean?

In your case this will be: /Applications/LiveCode/manage lists 2014.app/Contents/Resources
That is the folder where Apple DEMANDS to store all app related files and folders these days!


Best

Klaus

tomBTG
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 73
Joined: Fri Nov 25, 2011 6:42 pm
Location: Kansas City

Re: filepath differences IDE vs standalone

Post by tomBTG » Sat Jan 21, 2017 4:58 pm

Hi,
If you plan to distribute your app or to code sign your app or to place it in the Mac Applications folder, then the plan to write to files that are within the app bundle are likely to be blocked by Apple security limits.
Tom B.

slindstrom
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 29
Joined: Mon Apr 09, 2012 8:53 pm

Re: filepath differences IDE vs standalone

Post by slindstrom » Mon Jan 23, 2017 11:52 pm

Thanks, Paul, Klaus & Tom for your suggestions.

I will try Paul's code that varies based on whether the app is working in the IDE or as a standalone.

Klaus, your tip on specialFolderPath sounds like the ticket in theory. In practice, here's what I get.

specialFolderPath when called in the IDE provides this.

/Applications/LiveCode

specialFolderPath when called in the standalone provides this.

/Applications/LiveCode/manage lists 2014.app/Contents/Resources/_MacOS/

Note that the IDE version doesn't end with "/" but the standalone version does. So there is one other difference I will need to address between the IDE and standalone versions.

I also should have clarified that "1-meet data" is a folder to which the app "manage lists 2014" reads and writes. I do NOT include it in the app bundle because I don't want to overwrite or delete the data (text files) the user (me and one other colleague using a different Mac) have in that folder every time I update the app. I just tell my one user to put the standalone in the same folder that contains folder "1-meet data" on his computer and he should be good to go. This has worked with no problems for many years using standalones built with earlier versions of LC.

Thanks in advance for any further suggestions,

Sieg

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: filepath differences IDE vs standalone

Post by Klaus » Tue Jan 24, 2017 1:34 pm

Hi Sieg,
slindstrom wrote:...
specialFolderPath when called in the standalone provides this.
/Applications/LiveCode/manage lists 2014.app/Contents/Resources/_MacOS/
yes, true! Sorry, my fault.
slindstrom wrote:Note that the IDE version doesn't end with "/" but the standalone version does. So there is one other difference I will need to address between the IDE and standalone versions.
If that is the case, then this is a bug!
Please consider to report it here: http://quality.livecode.com
slindstrom wrote:I also should have clarified that "1-meet data" is a folder to which the app "manage lists 2014" reads and writes. I do NOT include it in the app bundle because I don't want to overwrite or delete the data (text files) the user (me and one other colleague using a different Mac) have in that folder every time I update the app. I just tell my one user to put the standalone in the same folder that contains folder "1-meet data" on his computer and he should be good to go. This has worked with no problems for many years using standalones built with earlier versions of LC.
Sorry, looks like I completely misunderstood what you were actually looking for!


Best

Klaus

Post Reply

Return to “Mac OS”