|
----- Original Message ----- From: steve donovan Date: 5/28/2009 12:12 AM FWIW, I have an extended version of lua-ex at svn://svn.luaplus.org/LuaPlus/work51/Src/Modules/lua-ex. It does the following above and beyond the original lua-ex:On Thu, May 28, 2009 at 1:33 AM, David Burgess <dburgess@gmail.com> wrote:Further, here is a minmal list of candidates for osex inclusion: basename(path) dirname(path)These can be done efficiently enough in Lua * Documentation on all APIs is included in the doc/ directory. * It compiles on Mac OS X. * Renamed currentdir() to getcwd(). * Added chmod(). * mkdir() recursively makes directory trees. * The replacement os.remove() has been extended to recursively destroy directory trees. * spawn() understands the following new fields: show - Show the application window (Windows only). shell - Run the application with cmd /C (Windows only). * Properly closes pipes under Lua 5.1. * Added a C-runtime-like access() function. * On Windows, the pipe() function takes an optional parameter to determine whether the pipe should be opened with "rt" or "wt" (like fopen) instead of the binary-only "r" or "w". * I added the wiki's windows.reg module. It has been extended with get_path() and set_path() functions. * The nasty automatic quoting of Windows arguments for spawn() has been removed. * ex.popen() and ex.popen2() are available, saving the user from duplicating popen2() from the example over and over. * ex.lines() is a nice iterator for spawning processes and reading their output. In addition, I extended lua-ex with a nice set of path manipulation functions: * os.path.add_extension(path, extension): Adds extension to the end of path even if one already exists. * os.path.add_slash(path): Adds a slash to the end of path if it doesn't already exist. * os.path.append(leftPath, rightPath): Appends leftPath and rightPath together, adding a slash between the two path components. If rightPath is an absolute path, it is not appended to leftPath and is returned directly. * os.path.combine(leftPath, rightPath): Combines leftPath and rightPath, adding a slash between the two path components and simplifying the path by collapsing . and .. directories. If rightPath is an absolute path, it is not appended to leftPath and is returned directly. * os.path.escape(path): Properly escapes and quotes path, if needed. * os.path.exists(path): Returns true if path exists, false otherwise. * os.path.find_extension(path): For the given path, return the index of the extension. Returns nil if the path has no extension. * os.path.find_filename(path): For the given path, return the index of the filename. * os.path.get_extension(path): For the given path, return the extension. * os.path.is_directory(path): Returns true if path is a directory, false otherwise. * os.path.is_file(path): Returns true if path is a file, false otherwise. * os.path.is_relative(path): Returns true if path is relative, false otherwise. * os.path.is_root(path): Returns true if path is a root path, false otherwise. * os.path.is_unc(path): Returns true if path is a UNC path, false otherwise. * os.path.make_absolute(path): Converts path into an absolute path, simplifying the path as necessary. * os.path.make_backslash(path): Convert any forward slashes in path to backslashes. * os.path.make_slash(path): Convert any backslashes in path to slashes. * os.path.match(path, wildcard): Returns true if the wildcard matches path, false otherwise. * os.path.remove_directory(path): Removes the directory component from path. * os.path.remove_extension(path): Removes the extension component from path. * os.path.remove_filename(path): Removes the filename component from path. * os.path.remove_slash(path): Removes the trailing slash from path. * os.path.replace_extension(path, extension): Replaces the extension of path with the new one specified in extension. * os.path.simplify(path): Simplifies path by collapsing . and .. directories and removing multiple directory slashes. * os.path.split(path): Splits path into directory and filename components. Returns both the directory and filename. * os.path.trim(path): Trims whitespace from the beginning and end of path. * os.path.unescape(path): Unescapes path. -Josh |