Setting file parameters
Files usually have parameters in addition to the information contained in the file itself. Such information is the owner of the file, the group the file belongs to, creation time, modify time, access time, change time and so on. To set these parameters of a file ScriptBasic provides the command set file.
The syntax of the command is
set file filename parameter=value
where `filename' is the name of the file for which the parameter is to be set, the parameter is the name of the parameter to change and value is the desired value of the parameter.
The parameter can be
- Owner to set the owner of the file. This owner is a user of the system identified by its login name. The owner of a file is usually the person who ran the program that created the file. The super user or administrator can change the owner of a file passing the ownership to any other legal user. The use of the command can be different on Windows NT from UNIX. Windows NT uses different NT domains and user names can be noted in the form DOMAIN\USER. The owner of a file on a machine belonging to one domain can be a user from another domain (that the domain the machine belongs to hopefully trusts). If the user name specified in the command chown contains a \ character (do not forget to use \\ in the strings) the user name is looked up in the domain specified in the name. If the name does not contain any domain specification the local user database is used.
- CreateTime to set the creation time of a file. The value for the time should be expressed in terms of seconds since January 1, 1970. 00:00. This is the usual measure of time on UNIX systems. This parameter does not exist on UNIX operation systems. UNIX maintains only modification, access time and change time, therefore setting CreateTime is not possible under UNIX and trying to perform the set file command for this parameter results error with error code sbErrorNotimp.
- ModifyTime to set the last modification time of a file. The value for the time should be expressed in terms of seconds since January 1, 1970. 00:00. This is the usual measure of time on UNIX systems.
- AccessTime to set the last access time of a file. The value for the time should be expressed in terms of seconds since January 1, 1970. 00:00. This is the usual measure of time on UNIX systems.
If the file does not exist or some other condition prevents the successful change of the parameter the program generates an error with one of the error codes sbErrorSetCreateTime, sbErrorSetModifyTime, sbErrorSetAccessTime.
Note that Windows NT file system (NTFS) and UNIX operating systems store file time values in GMT. Do not forget to convert the local time to GMT if needed when changing some of the file time values. Other file systems, like FAT may store the file times as local time. Be careful.