Is it possible to write to the filesystem from a lua script?

Discuss your Lua playlist, album art and interface scripts.
NoMoreNicksLeft
Blank Cone
Blank Cone
Posts: 21
Joined: 06 Aug 2012 19:39

Is it possible to write to the filesystem from a lua script?

Postby NoMoreNicksLeft » 08 Aug 2012 23:35

What I had in mind was writing a playlist script named something like zzzzzzzzzz.lua. As I understand it, since it would come last (alphabetical order) it would be ignored if any other scripts matched. If all the others failed to match, this script would be written to return true on the probe no matter what though. Inside, it would look for a single tag, something like:

Code: Select all

<meta name="videolan-playlist" href="/path/to/lua-playlist.lua"/>
And if it found such a tag, it'd go ahead and prompt the user to install that script (well, I think dialog is turned off for everything but extensions, but you get the idea).

I can't find anything in the READMEs about filesystem access though, not even to say that it is only possible in extensions. Where should I be looking?

mark_
New Cone
New Cone
Posts: 2
Joined: 15 Aug 2012 14:24

Re: Is it possible to write to the filesystem from a lua scr

Postby mark_ » 15 Aug 2012 14:27

yes, you can use the os and file and io functions listed here:
http://www.lua.org/manual/5.1/

NoMoreNicksLeft
Blank Cone
Blank Cone
Posts: 21
Joined: 06 Aug 2012 19:39

Re: Is it possible to write to the filesystem from a lua scr

Postby NoMoreNicksLeft » 16 Aug 2012 02:26

I'm having no luck with that. I've tried the following code inside of a playlist script:

Code: Select all

fh = io.open('test.txt', "w") fh:write("test is a test") fh:flush() fh:close()
I was expecting it to attempt to create a file somewhere within VLC's own directory tree, but it's nowhere to be found. However, the statements after this execute perfectly... throws no errors or warnings. I can't find any scripts in the VLC source either that make use of this either.

NoMoreNicksLeft
Blank Cone
Blank Cone
Posts: 21
Joined: 06 Aug 2012 19:39

Re: Is it possible to write to the filesystem from a lua scr

Postby NoMoreNicksLeft » 16 Aug 2012 15:39

Mark,

Turns out you were right. I can write to the filesystem... it's just that when I run it from the term it was writing to my home directory. When running from the dock, it'd drop things in root. So I have to qualify the filename with an absolute path, but I've yet to figure out how to determine which OS I'm on (hoping to find the playlist directory so that I can have my playlist script update itself).


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 7 guests