Locked files

Locked files

Anonymous
Not applicable
439 Views
7 Replies
Message 1 of 8

Locked files

Anonymous
Not applicable
Hi, Im creating a game level exporter, I use the createFile in script and fills it with all the data I need, and then I want to launch an outside program to encrypt it, this process fails because the created file is locked as long as 3ds max i open, is there a way to get around this?


Thanks
// Scanmaster_K
0 Likes
440 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
You need to close the file when you are done sending data to it.

tex_out = createFile tex_out

-- Do some text dumping here --

close tex_out

If your script errors out before closing the file, you can run gc() to free up the
file.
0 Likes
Message 3 of 8

Anonymous
Not applicable
Sorry, forgot to say, but do close the file, it is still locked.
0 Likes
Message 4 of 8

Anonymous
Not applicable
can you post the pieces of what you're trying to do...might be a simple syntax thing, but
without something to look at it's hard to debug.
0 Likes
Message 5 of 8

Anonymous
Not applicable
First I create the file.

outputName = getSaveFileName "Exitman Exporter" types:"Exitman Level(*.lvl)|*.lvl"
if outputName != undefined then (
outputFile = createFile outputName


Then I write alot of stuff to it like this
format "\t\tname=\"%\"\n" subInformation.txtTitle.text to:outputFile
format "\t\tnextLevel=\"%\"\n" subInformation.txtNextLevel.text to:outputFile
format "\t\tteam=\"%\"\n\t>\n" subAuthor.txtTeam.text to:outputFile


then
close outputFile


and then I do (pseydo code as I removed it because it didn't work).

if chkEncrypt.checked == true then (
ShellLaunch "lzma.exe e inputFile outputFile" ""
)
0 Likes
Message 6 of 8

Anonymous
Not applicable
shouldn't the shell launch be outputname not outputfile?
Outputfile is the filestream object.
0 Likes
Message 7 of 8

Anonymous
Not applicable
of course, the shellLaunch thigns works correctly though, its just that the exe file cant encrypt the file as it is locked.
0 Likes
Message 8 of 8

Anonymous
Not applicable
Sorry...I'm tired...

If I'm not mistaken lzma is a dos command...so you should use:

doscommand ("lzma.exe e " + inputFile + outputFile)
as an alternate (to see the dos output)

doscommand ("cmd /k lzma.exe e " + inputFile + outputFile)

If that doesn't work...I dunno...look for early termination (before the close file)
0 Likes