lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Edgar Toernig wrote:
D Burgess wrote:

I understand, someone correct me if I am wrong that on
Unix unlink will remove the file when the last user of it
closes the file.


The name is removed immediately but the contents of the
file may stay and is removed only when the last user closes
the file.

The difference between unlink and remove is, that unlink won't
delete directories.  remove does as long as the directory is
empty.  On older system which lack remove you had to call rmdir
the delete directories.

Yes, I see that the posix spec says this explicitly. Furthermore it says that you cannot remove non-empty directories. So maybe we should get rid of rmdir() from osex, since remove() in os can do this functionality. And you can discover if a file is a regular file or directory using osex.stat().

I'd also like to argue that we toss osex.getenv() since this function is in os as well. I originally thought we should keep it for completeness. But now I think we should minimize the footprint of osex. I would also like to replace putenv() with a setenv(name[,value]) function. This avoids the need to construct the putenv string. And it allows the name to be removed from the environment by omitting value. The original lposix package had this, but it had a third 'overwrite' param. I don't think this is needed, since you can see if a variable exists with os.getenv() and then avoid calling osex.setenv() if so.

I have also added a files() function, so here is the current proposed list:

access(path,[mode])	test file accessibility
chdir(path)		make the given path the cwd
chmod(path,mode)	change permissions on the path to the mode str
errno()			return the last error string,number
files([path])		return an iterator for the passed path
getcwd()		return the cwd
mkdir(path)		create a directory at the passed path
setenv(name[,value])	set a value in the environment
sleep(sec)		sleep for the passed number of seconds
stat(path,[selector])	return status for the file at the passed path
umask([mode])		set the mask for future file creations

I think that's a pretty complete set for starters. I have implemented this set for Win32 using MSDev 7.1. I will send the code as soon as I have tested it.

--
chris marrin              ,""$, "As a general rule,don't solve puzzles
chris@marrin.com        b`    $  that open portals to Hell" ,,.
        ,.`           ,b`    ,`                            , 1$'
     ,|`             mP    ,`                              :$$'     ,mm
   ,b"              b"   ,`            ,mm      m$$    ,m         ,`P$$
  m$`             ,b`  .` ,mm        ,'|$P   ,|"1$`  ,b$P       ,`  :$1
 b$`             ,$: :,`` |$$      ,`   $$` ,|` ,$$,,`"$$     .`    :$|
b$|            _m$`,:`    :$1   ,`     ,$Pm|`    `    :$$,..;"'     |$:
P$b,      _;b$$b$1"       |$$ ,`      ,$$"             ``'          $$
 ```"```'"    `"`         `""`        ""`                          ,P`