I. File Location relocation function:
1. Rename () function: rename a file
$ Ret = Rename (oldname, newname );
This function is used to rename the old file name oldname to a new name newname, or transfer the file oldname to the specified directory newname. Both parameters can be strings or expressions; if oldname and newname are both file names or directory names, and oldname and newname have the same directory names, the function will rename them. If oldname and newname have the same file names, however, if the path is different, the function completes file transfer;
If the call is successful, a non-zero value (true: 1) is returned. If the call fails, a zero value (false: 0) is returned );
That is to say, if the file is successfully renamed or transferred, the rename () function returns a non-zero value (true: 1); if the file fails to be renamed or transferred, the rename () function returns a zero value (false: 0 );
2. Unlink () function: delete an object
$ Unlinkfilenumbers = unlink (filelist );
This function is used to delete a file. The parameter is a list of file names or a simple variable that stores a file name. The return value of the function is the number of files actually deleted. This function is called unlink instead of Delete because unlink () what the function actually does is delete the file link, instead of deleting the file. Because the Unix/Linux system sets a link count for each file, each time a file is deleted, in fact, it is to delete a link to the file and reduce the link count by 1. The operating system will delete the file only when the link count is changed to 0;
If the function is successfully called, the number of actually deleted files (non-zero, true) is returned. If the call fails, the value 0 is returned (false: 0 );
That is to say, if the object is successfully deleted, the unlink () function returns the number of objects actually deleted (non-zero, true); if the object fails to be deleted, the unlink () function returns a zero value (false: 0 );
Ii. File hard connection and symbolic connection
1. Link () function:
$ Ret = Link (file, hardlinkname );
This function is used to create a hard link hardlinkname for the file. file is the source of the Link (the file to be linked), and hardlinkname is the name of the newly created link; when you delete one of the two names "file" and "hardlinkname", you can still use another name to access the content of the file;
If the function is successfully called, a non-zero value (true: 1) is returned. If the call fails, a zero value (false: 0) is returned. That is, if the hard link hardlinkname created to the file is successful, the Link () function returns a non-zero value (true: 1); if the hard link hardlinkname created to the file fails, the link () function returns a zero value (false: 0 );
2. symlink () function:
$ Ret = symlink (file, symlinkname );
This function creates a symbolic link symlinkname for the existing file, that is, this symbolic link only points to the file name, not to the file itself; what is the return value of the parameter and link () the functions are the same. When the source file is deleted, the created symbolic link is no longer available unless you create another file with the same name as the file;
If the call is successful, the function returns a non-zero value (true: 1); if the call fails, the function returns a zero value (false: 0); that is, when the symlinkname of the symbolic link to the file is successfully created, the symlink () function returns a non-zero value (true: 1); when the symlinkname of the symbolic link created to the file fails, the symlink () the function returns zero (false: 0 );
3. readlink () function:
$ Filename = readlink (symlinkname );
If the parameter symlinkname is a symbolic link file, the function returns the actual file name pointed to by the symbolic link; otherwise, an empty string is returned;
Iii. File Permission permit Functions
1. chmod () function:
$ Ret = chmod (permissions, filelist );
This function is used to change the object access permission in the filelist file list to the permission specified by the permissions parameter;
The chmod () function returns the number of files in the filelist file list that have been successfully changed to the access permission. It does not distinguish whether the call is successful or not;
2. chown () function:
$ Ret = chown (newuserid, newgroupid, filelist );
Used to change the owner of all files in the filelist file list;
Newuserid: New User ID (number );
Newgroupid: New Group ID (number);-1 indicates retaining the original group;
Filelist: list of files to be changed to the owner;
The chown () function returns the number of objects in the filelist file list that have been successfully changed by the owner. If no call is successful;
3. umask () function:
Oldmask = umask (newmask );
This function is used to set the file access permission mask. This function receives a new parameter mask newmask and returns the oldmask, which is currently in use;
4. other attribute functions:
1. truncate () function:
$ Ret = truncate (file, length );
This function reduces the length of the file specified by the parameter file to length bytes. If the file length is less than the Length byte, the function does nothing. The parameter file can be a file name or a file handle;
If the function is successfully called, The truncate () function returns a non-zero value (true: 1); if the call fails, a null value (false) is returned );
2. Stat () function:
@ Filestates = Stat (File );
This function is used to obtain the file state. The parameter file can be either a file name or a file handle;
If the call is successful, the property list of the file is returned. If the call fails, a null value is returned;
The Stat () function returns a list of elements used to store file attributes. The order of the elements in the list is:
Filestates [0]: The device where the file is located;
Filestates [1]: file internal reference number (inode );
Filestates [2]: access permission;
Filestates [3]: Number of hard connections;
Filestates [4]: The owner's ID (number );
Filestates [5]: Group ID (number );
Filestates [6]: device type (if file is a device );
Filestates [7]: file size (number of bytes );
Filestates [8]: creation time;
Filestates [9]: last modification time or last State modification time hh: mm: SS (00:00:00 ~ 23:59:59 );
Filestates [10]: Last access time;
Filestates [11]: The best block size for Io operations;
Filestates [12]: number of blocks allocated to the file;
3. lstat () function:
@ Filestates = lstat (File );
This function is similar to the stat () function, but the difference is that the function regards the parameter file as a symbolic link;
If the call is successful, the property list of the file is returned. If the call fails, a null value is returned;
The structure of the returned attribute list is the same as that of the attribute list returned by STAT;
4. Time () function:
Returns the cumulative number of seconds from 00:00:00, January 1, January 1, 1970 to the current time;
$ Currenttime = Time ();
5. gmtime () functions:
@ Timeelemlist = gmtime (timevalue );
This function converts the time returned by time (), Stat (), and file test operators-A and-M to Greenwich Mean Time, and returns a list containing time elements: @ timeelemlist;
The returned Time element list @ timeelemlist contains the following elements:
Timeelemlist [0]: seconds (0 ~ 59 );
Timeelemlist [1]: minute (0 ~ 59 );
Timeelemlist [2]: hour (0 ~ 23 );
Timeelemlist [3]: Day (1 ~ 31 );
Timeelemlist [4]: Month (0 ~ 11: September January ~ December );
Timeelemlist [5]: Year;
Timeelemlist [6]: Week;
Timeelemlist [7]:
Timeelemlist [8]: