0

I have tried to make a directory using MkDir in Lotusscript. I want to create a Temp folder in Mac. It does not allow me to create /Users/Temp/.

What are other alternatives to create a Temp in Mac. Example creating it /Users but name of users e.g. /Users/name/Temp. In this case how do you use lotus script to create Temp folder for any users.

Nimantha
  • 6,405
  • 6
  • 28
  • 69

3 Answers3

1

It should be possible do this with mkdtemp the standard c library call, as described in this question. In LotusScript you would want a function declaration like this :

Declare Function mkdtemp Lib "libc" ( template as String ) as String

and call it using something like :

Dim template As String*512 
Dim tempFolder As String*512

template = "/tmp/myFolderXXXXXX" & chr(0)
tempFolder = String( 512,0 )
tempFolder =  mkdtemp( template )

I don't have a mac so this might need a tweak to work correctly.

Simon Delicata
  • 401
  • 5
  • 15
0

Difference between creating a folder in /Users vs. /Users/yourname is that in Users you do not have rights to write (or create folder), while you can write in your home directory (/Users/yourname).

The problem to create subdirectories in /tmp is the same - you do not have the rights.

Your best bet would be to use Environ$("TMPDIR") that returns a path to a temporary directory for the current user. There you can create your own folder.

To create a portable code, you could probably loop through "TMP", "TEMP", "TMPDIR" variables until you find one returning a value. This way you can find temp folder on Windows as well. On Linux you do not have an environment variable, but /tmp is writable for everyone.

Normunds Kalnberzins
  • 1,213
  • 10
  • 20
0

I have found a way. It works if you put it in shared /Users/Shared/. Thought to share to everyone.