Artem Crum Posted May 16, 2011 Report Posted May 16, 2011 Hello, Pete I need to get list of directories from Lua script (script is running inside FSX/FSUIPC) and have a problem with it. I can use os.execute or os.popen calls to run DIR command and then parse it's output. It works but they both open black-DOS-window (cmd.exe actually) to run this DIR command. This window appears for a moment an dissappears again. Not a big problem but distracting and I want to get rid of this. Other way to do this is to load some Lua library containing native dirctory listing functions. I was trying "LuaFileSystem" library but it crashes the FSX when loaded. Is there any other way to get dir. listing? Or may by to load "LuaFileSystem" without a crash?
Pete Dowson Posted May 16, 2011 Report Posted May 16, 2011 Other way to do this is to load some Lua library containing native dirctory listing functions. I was trying "LuaFileSystem" library but it crashes the FSX when loaded. I don't know that library, but if it is made as a C module (DLL) loaded by Lua then the answer might be available later today. Please see the thread near here entitled "Lua capabilities". I have, I think, located and fixed the problems in handling Lua C modules, though it needs some more testing. Read it to the end where I am about to post details of the solution. Regards, Pete
Artem Crum Posted May 16, 2011 Author Report Posted May 16, 2011 (edited) Thank you for your fast reply, Pete. LuaFileSystem - is a common library often distributed with Lua. I'm not the author of it and didn't compile it myself. But it's quite small and simple - 17kb of source code with just few functions implemented. Info could be found here: http://keplerproject.../luafilesystem/ Sources are here: http://luaforge.net/...ystem-1.4.2.zip I have read "Lua capabilities" thread but actually not understanding your solution recomendations (I'm not a C-programmer). May be you can include LuaFileSystem in your FSUIPC-internal Lua implementation in some future versions? Edited May 16, 2011 by Artem Crum
Artem Crum Posted May 16, 2011 Author Report Posted May 16, 2011 Oh! Just saw your last reply in Lua capabilities... waiting for new version to be uploaded.
Pete Dowson Posted May 16, 2011 Report Posted May 16, 2011 Oh! Just saw your last reply in Lua capabilities... waiting for new version to be uploaded. There now. May be you can include LuaFileSystem in your FSUIPC-internal Lua implementation in some future versions? I don't know. I'll take a look. Pete
Artem Crum Posted May 16, 2011 Author Report Posted May 16, 2011 Yes! It magically work now! Great thanks, Pete! Little question is left... Library is loaded but it requires lua5.1.dll to be placed inside the root FSX folder. When I put this dll in FSX/modules or FSX/modules/lua it doesn't work. Is it ok? Or where should I place this library?
Pete Dowson Posted May 16, 2011 Report Posted May 16, 2011 Yes! It magically work now! Great thanks, Pete! Great! Thanks! That's a first real test! ;-) Little question is left... Library is loaded but it requires lua5.1.dll to be placed inside the root FSX folder. When I put this dll in FSX/modules or FSX/modules/lua it doesn't work. That's odd. It should be okay next to the DLL which needs it, i.e. in the FSX/modules/lua folder. Is it ok? Or where should I place this library? It'll be okay in FSX root, but I'll have to look to see why the LoadLibraryEx routine isn't searching the same folder as the module itself. Maybe it only looks in the current process folder (FSX.EXE) and, of course, the Windows and Windows\System folders. If so I don't think I can do much about it. It isn't really my code which controls it, and any solution I could work out (which would be quite convoluted) wouldn't apply to any lower needs in the chain -- i.e. should the module loaded want then to load another Lua library module. Regards Pete
Artem Crum Posted May 16, 2011 Author Report Posted May 16, 2011 Ok, will be glad to hear any news about DLLs placement. Anyhow, you are doing a marvelous job as always! :-D
Pete Dowson Posted May 16, 2011 Report Posted May 16, 2011 Ok, will be glad to hear any news about DLLs placement. As posted in the other thread: There's a Windows API called "SetDLLDirectory", which adds a path to the list for DLL searching. I'll get FSUIPC to add "Modules\Lua" and "Modules\DLL" for the entire session. That should deal with it! But i'll leave this till i return from holiday, by which time hopefully the modules facility will have been well and truly tested! I might also then incorporate the LuaFileSystem (lfs) library into FSUIPC and Wideclient. It looks useful and won't add noticeably to FSUIPC's size. I'm on holiday from Wednesday evening till the first Wednesday in June. BTW, Apparently ou can also get the Modules\Lua folder searched by specifying it in the PATH environment variable. Environment settings used to be common place in DOS and early Windows days. I'm not sure how to set them in modern Windows. Regards Pete
Artem Crum Posted May 16, 2011 Author Report Posted May 16, 2011 Great news once again. Happy holidays!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now