0

I'm download file from url and I want to put file to Home directory(Users/myname/livecode).

This my code :

      set the itemDel to slash
      put last item of pURL into tFilename
      put specialFolderPath("Users/myname") & slash before tFileName
      put URL pURL into URL ("binfile:" & tFileName)

My platform is MAC OS.

KemChat
  • 151
  • 3
  • 11

2 Answers2

0

I'm not sure if 'Users' works as an identifier. If it does, you can try;

put specialFolderPath("Users") & slash & myname & slash before tFileName

If it doesn't, the following may work;

put specialFolderPath("Home") & slash before tFileName

The 'Home' identifier should give the current user's home folder.

splash21
  • 799
  • 4
  • 10
  • 1
    `specialFolderpath("home")` works. Only pre-defined parameters work. You can find a list of these parameters in the LiveCode Dictionary. Besides these parameters, you can use numbers. My book Programming LiveCode for the Real Beginner contains a complete list with all possible values. It is probably much longer than you imagined. – Mark Apr 30 '14 at 07:57
  • 1
    at http://sonsothunder.com/devres/livecode/tips/file010.htm you find a complete overview of possible values for specialfolderpath – Matthias Rebbe Apr 30 '14 at 08:01
  • That link is slightly outdated and doesn't contain all values for MacOS. – Mark Apr 30 '14 at 08:32
  • But to get a detailed overview right now it is much faster to visit that page now than waiting for your book to arrive. ;) Without question your book is a very useful source of information! – Matthias Rebbe Apr 30 '14 at 09:17
0

Regarding your question/sample to put the file into a subfolder in the home folder called livecode you could do it this way:

set the itemDel to slash
  put last item of pURL into tFilename

  //set the target folder ("~" works on Mac OS X and Linux)
  put "~/livecode" into tTargetFolder

  //check if the folder livecode already exists, if not then create it
  if there is not a folder tTargetFolder then create folder tTargetfolder

  put tTargetfolder and slash before tFileName
  // tFilename now contains the complete path

  put URL pURL into URL ("binfile:" & tFileName)    

Using "~" instead using specialfolderpath("home") helps to spent some typing. But be aware that "~" only works under Mac OS X and Linux.

Matthias Rebbe
  • 116
  • 1
  • 7
  • I would prefer the solution with "home", because it works on Mac OS X, Linux _and_ Windows. – Mark Apr 30 '14 at 08:29