| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 |
"http://www.w3.org/TR/html4/strict.dtd"> |
| 3 |
<html> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| 6 |
<title>getfileattr</title> |
| 7 |
<meta http-equiv="Content-Style-Type" content="text/css"> |
| 8 |
<link rel="stylesheet" href="../../style.css" type="text/css"> |
| 9 |
</head> |
| 10 |
|
| 11 |
<body> |
| 12 |
|
| 13 |
|
| 14 |
<h1>getfileattr</h1> |
| 15 |
|
| 16 |
<p> |
| 17 |
Returns the attributes of a file or directory. <em>(version 4.69 or later)</em> |
| 18 |
</p> |
| 19 |
|
| 20 |
<pre class="macro-syntax"> |
| 21 |
getfileattr <filename> |
| 22 |
</pre> |
| 23 |
|
| 24 |
<h2>Parameters</h2> |
| 25 |
|
| 26 |
<dl> |
| 27 |
<dt class="macro">string <filename></dt> |
| 28 |
<dd>The file name or directory name</dd> |
| 29 |
</dl> |
| 30 |
|
| 31 |
<h2>Return Value</h2> |
| 32 |
|
| 33 |
<dl> |
| 34 |
<dt class="macro">System variable <result></dt> |
| 35 |
<dd>When this command fails, -1 is stored.<br> |
| 36 |
When the command succeeds, the returned value is in the following:<br> |
| 37 |
<table border="2"> |
| 38 |
<tr> |
| 39 |
<th>Value</th> |
| 40 |
<th>Meaning</th> |
| 41 |
</tr> |
| 42 |
<tr> |
| 43 |
<td>$1</td> |
| 44 |
<td>Read only</td> |
| 45 |
</tr> |
| 46 |
<tr> |
| 47 |
<td>$2</td> |
| 48 |
<td>Hidden</td> |
| 49 |
</tr> |
| 50 |
<tr> |
| 51 |
<td>$4</td> |
| 52 |
<td>The operating system uses a part of, or uses exclusively</td> |
| 53 |
</tr> |
| 54 |
<tr> |
| 55 |
<td>$10</td> |
| 56 |
<td>Directory</td> |
| 57 |
</tr> |
| 58 |
<tr> |
| 59 |
<td>$20</td> |
| 60 |
<td>Archive</td> |
| 61 |
</tr> |
| 62 |
<tr> |
| 63 |
<td>$80</td> |
| 64 |
<td>Not have other attributes set</td> |
| 65 |
</tr> |
| 66 |
<tr> |
| 67 |
<td>$100</td> |
| 68 |
<td>Temporary</td> |
| 69 |
</tr> |
| 70 |
<tr> |
| 71 |
<td>$200</td> |
| 72 |
<td>Sparse file</td> |
| 73 |
</tr> |
| 74 |
<tr> |
| 75 |
<td>$400</td> |
| 76 |
<td>Has an associated reparse point, or a file that is a symbolic link</td> |
| 77 |
</tr> |
| 78 |
<tr> |
| 79 |
<td>$800</td> |
| 80 |
<td>Compressed</td> |
| 81 |
</tr> |
| 82 |
<tr> |
| 83 |
<td>$1000</td> |
| 84 |
<td>Physically moved to offline storage(Windows 2000 or later)</td> |
| 85 |
</tr> |
| 86 |
<tr> |
| 87 |
<td>$2000</td> |
| 88 |
<td>Not to be indexed by the content indexing service(Windows 2000 or later)</td> |
| 89 |
</tr> |
| 90 |
<tr> |
| 91 |
<td>$4000</td> |
| 92 |
<td>Encrypted</td> |
| 93 |
</tr> |
| 94 |
</table> |
| 95 |
</dd> |
| 96 |
</dl> |
| 97 |
|
| 98 |
<h2>Example</h2> |
| 99 |
|
| 100 |
<pre class="macro-example"> |
| 101 |
file = 'c:\test.txt' |
| 102 |
getfileattr file |
| 103 |
if result <> -1 then |
| 104 |
if result & $1 > 0 then |
| 105 |
messagebox 'This file has readonly attribute.' file |
| 106 |
endif |
| 107 |
endif |
| 108 |
</pre> |
| 109 |
|
| 110 |
<pre class="macro-example"> |
| 111 |
name = "C:\test" |
| 112 |
|
| 113 |
getfileattr name |
| 114 |
|
| 115 |
if result < 0 then |
| 116 |
messagebox "Not found" name |
| 117 |
elseif result & $10 then |
| 118 |
messagebox "Directory" name |
| 119 |
else |
| 120 |
messagebox "File" name |
| 121 |
endif |
| 122 |
</pre> |
| 123 |
|
| 124 |
<h2>See also</h2> |
| 125 |
<ul> |
| 126 |
<li><a href="setfileattr.html">setfileattr</a></li> |
| 127 |
<li>MSDN Library <a href="http://msdn.microsoft.com/en-us/library/aa364944(v=VS.85).aspx" target="_blank">GetFileAttributes</a></li> |
| 128 |
<li>MSDN Library <a href="http://msdn.microsoft.com/en-us/library/gg258117(v=VS.85).aspx" target="_blank">File Attribute Constants</a></li> |
| 129 |
</ul> |
| 130 |
|
| 131 |
</body> |
| 132 |
</html> |