filesys
help for filesys
filesys – a Java plugin to access filesystem properties of files.
Syntax
filesys filename, [ attributes display global readable(string) writable(string) xecutable(string) readonly ]
Description
filesys is designed to provide access to basic file system properties. In addition, it provides some basic functionality to allow setting properties on files without having to write OS specific code to do the same from the shell. See return values for additional information regarding the attributes that are exposed from this program.
Options
attributes this option is used to retrieve the properties of a file and does not make any modifications to the file system properties for the file.
display prints a table showing the file system properties to the Results window.
global is an option used in conjunction with readable, writable, or xecutable to set the property on/off for all users.
readable(on|off) is an option used to set the readable property for the file on or off. If the global option is not specified it will set this property for the current user only.
writable(on|off) is an option used to set the readable property for the file on or off. If the global option is not specified it will set this property for the current user only.
xecutable(on|off) is an option used to set the executable property for the file on or off. (Note: the misspelling here is intended to reflect the way the properties are declared in *nix based systems). If the global option is not specified it will set this property for the current user only.
readonly is an option used to set the file to readonly mode. There is no option to apply this globally vs locally.
Examples
Ex 1.
View the properties of the auto.dta dataset
. filesys `c(sysdir_base)'a/auto.dta, attr dis
------------------------------------
Attribute File Attribute Value
------------------------------------
Created Date 20nov2015 05:44:54
Modified Date 20nov2015 05:44:54
Last Accessed Date 11dec2015 05:52:23
Absolute File Path /Applications/Stata/ado/base/a/auto.dta
Canonical File Path /Applications/Stata/ado/base/a/auto.dta
Parent Path /Applications/Stata/ado/base/a
File Name auto.dta
Is Symbolic Link false
Is Regular File true
Is Executable false
Is Hidden false
Is Readable true
Is Writable true
------------------------------------
Ex 2.
Make the file globally executable
. filesys `c(sysdir_base)'a/auto.dta, glo x(on) dis
------------------------------------
Attribute File Attribute Value
------------------------------------
Created Date 20nov2015 05:44:54
Modified Date 20nov2015 05:44:54
Last Accessed Date 11dec2015 05:52:23
Absolute File Path /Applications/Stata/ado/base/a/auto.dta
Canonical File Path /Applications/Stata/ado/base/a/auto.dta
Parent Path /Applications/Stata/ado/base/a
File Name auto.dta
Is Symbolic Link false
Is Regular File true
Is Executable true
Is Hidden false
Is Readable true
Is Writable true
------------------------------------
Ex 3.
Turn off the executable property
. filesys `c(sysdir_base)'a/auto.dta, glo x(off) dis
------------------------------------
Attribute File Attribute Value
------------------------------------
Created Date 20nov2015 05:44:54
Modified Date 20nov2015 05:44:54
Last Accessed Date 11dec2015 05:52:23
Absolute File Path /Applications/Stata/ado/base/a/auto.dta
Canonical File Path /Applications/Stata/ado/base/a/auto.dta
Parent Path /Applications/Stata/ado/base/a
File Name auto.dta
Is Symbolic Link false
Is Regular File true
Is Executable false
Is Hidden false
Is Readable true
Is Writable true
------------------------------------
Ex 4.
A few other examples of modifying the attributes of an individual file
// Turn on the writable property
. filesys `c(sysdir_base)'a/auto.dta, glo w(on)
// Turn off the writable property
. filesys `c(sysdir_base)'a/auto.dta, glo w(off)
// Turn off the writable property for the current user only
. filesys `c(sysdir_base)'a/auto.dta, w(off)
// Turn on the readable property and suppress output
. filesys `c(sysdir_base)'a/auto.dta, glo r(on)
// Turn off the readable property
. filesys `c(sysdir_base)'a/auto.dta, glo r(off)
Returned values
Macro Name | Value |
---|---|
r(iswritable) | Boolean indicator if file is writable |
r(isreadable) | Boolean indicator if file is readable |
r(parentpath) | String with path to parent directory |
r(ishidden) | Boolean indicator if file is hidden |
r(filename) | String name of the file w/o filepath |
r(isexecutable) | Boolean indicator if file is executable |
r(canonicalpath) | OS specific absolute path |
r(absolutepath) | Generic absolute path |
r(filesize) | Size of the file in bytes |
r(regularfile) | Boolean indicator if file is a regular file (not directory/symbolic link) |
r(symlink) | Boolean indicator if file is a symbolic link |
r(accessednum) | SIF Value of the last accessed date use %tc for the display format |
r(modifiednum) | SIF Value of the modified date use %tc for the display format |
r(creatednum) | SIF Value of the created date use %tc for the display format |
r(accessed) | String containing the date last modified |
r(modified) | String containing the modified date |
r(created) | String containing the created date |