@@ -54,7 +54,7 @@ void Stat::fill(exlib::string path, uv_stat_t* statbuf)
54
54
55
55
dev = statbuf->st_dev ;
56
56
ino = statbuf->st_ino ;
57
- mode = statbuf->st_mode ;
57
+ m_mode = statbuf->st_mode ;
58
58
59
59
nlink = statbuf->st_nlink ;
60
60
@@ -80,26 +80,6 @@ void Stat::fill(exlib::string path, uv_stat_t* statbuf)
80
80
birthtimeNs = (double )statbuf->st_birthtim .tv_nsec ;
81
81
birthtime = (double )statbuf->st_birthtim .tv_sec * 1000ll + (birthtimeNs / 1000000000.0 );
82
82
83
- #ifdef _WIN32
84
- m_isBlockDevice = false ;
85
-
86
- m_isCharacterDevice = false ;
87
- m_isFIFO = false ;
88
- #else
89
- m_isBlockDevice = S_ISBLK (statbuf->st_mode );
90
- m_isCharacterDevice = S_ISCHR (statbuf->st_mode );
91
- m_isFIFO = S_ISFIFO (statbuf->st_mode );
92
- #endif
93
-
94
- m_isReadable = (S_IRUSR & statbuf->st_mode ) != 0 ;
95
- m_isWritable = (S_IWUSR & statbuf->st_mode ) != 0 ;
96
- m_isExecutable = (S_IXUSR & statbuf->st_mode ) != 0 ;
97
-
98
- m_isDirectory = (S_IFDIR & statbuf->st_mode ) != 0 ;
99
- m_isFile = (S_IFREG & statbuf->st_mode ) != 0 ;
100
-
101
- m_isSymbolicLink = S_ISLNK (statbuf->st_mode );
102
-
103
83
m_isMemory = false ;
104
84
m_isSocket = false ;
105
85
}
@@ -108,7 +88,7 @@ void Stat::init()
108
88
{
109
89
name.resize (0 );
110
90
size = 0 ;
111
- mode = 0 ;
91
+ m_mode = 0 ;
112
92
113
93
mtime = 0 ;
114
94
mtimeNs = 0 ;
@@ -121,22 +101,6 @@ void Stat::init()
121
101
122
102
gid = 0 ;
123
103
uid = 0 ;
124
-
125
- m_isBlockDevice = false ;
126
- m_isCharacterDevice = false ;
127
- m_isFIFO = false ;
128
-
129
- m_isReadable = false ;
130
- m_isWritable = false ;
131
- m_isExecutable = false ;
132
-
133
- m_isDirectory = false ;
134
- m_isFile = false ;
135
-
136
- m_isSymbolicLink = false ;
137
-
138
- m_isMemory = false ;
139
- m_isSocket = false ;
140
104
}
141
105
142
106
void Stat::init (Stat_base* st)
@@ -150,7 +114,7 @@ void Stat::init(Stat_base* st)
150
114
size = d_tmp;
151
115
152
116
st->get_mode (i32_tmp);
153
- mode = i32_tmp;
117
+ m_mode = i32_tmp;
154
118
155
119
st->get_mtime (mtime);
156
120
st->get_atime (atime);
@@ -163,19 +127,6 @@ void Stat::init(Stat_base* st)
163
127
st->get_uid (i32_tmp);
164
128
uid = i32_tmp;
165
129
166
- // st->isBlockDevice(m_isBlockDevice);
167
- // st->isCharacterDevice(m_isCharacterDevice);
168
- // st->isFIFO(m_isFIFO);
169
-
170
- st->isReadable (m_isReadable);
171
- st->isWritable (m_isWritable);
172
- st->isExecutable (m_isExecutable);
173
-
174
- st->isDirectory (m_isDirectory);
175
- st->isFile (m_isFile);
176
-
177
- st->isSymbolicLink (m_isSymbolicLink);
178
-
179
130
st->isMemory (m_isMemory);
180
131
st->isSocket (m_isSocket);
181
132
}
@@ -200,7 +151,7 @@ result_t Stat::get_ino(int32_t& retVal)
200
151
201
152
result_t Stat::get_mode (int32_t & retVal)
202
153
{
203
- retVal = mode ;
154
+ retVal = m_mode ;
204
155
return 0 ;
205
156
};
206
157
@@ -296,19 +247,22 @@ result_t Stat::get_birthtimeMs(double& retVal)
296
247
297
248
result_t Stat::isWritable (bool & retVal)
298
249
{
299
- retVal = m_isWritable;
250
+ retVal = (S_IWUSR & m_mode) != 0 ;
251
+
300
252
return 0 ;
301
253
}
302
254
303
255
result_t Stat::isReadable (bool & retVal)
304
256
{
305
- retVal = m_isReadable;
257
+ retVal = (S_IRUSR & m_mode) != 0 ;
258
+
306
259
return 0 ;
307
260
}
308
261
309
262
result_t Stat::isExecutable (bool & retVal)
310
263
{
311
- retVal = m_isExecutable;
264
+ retVal = (S_IXUSR & m_mode) != 0 ;
265
+
312
266
return 0 ;
313
267
}
314
268
@@ -318,33 +272,71 @@ result_t Stat::isHidden(bool& retVal)
318
272
return 0 ;
319
273
}
320
274
275
+ result_t Stat::isBlockDevice (bool & retVal)
276
+ {
277
+ #ifdef _WIN32
278
+ retVal = false ;
279
+ #else
280
+ retVal = S_ISBLK (m_mode);
281
+ #endif
282
+
283
+ return 0 ;
284
+ }
285
+
286
+ result_t Stat::isCharacterDevice (bool & retVal)
287
+ {
288
+ #ifdef _WIN32
289
+ retVal = false ;
290
+ #else
291
+ retVal = S_ISCHR (m_mode);
292
+ #endif
293
+
294
+ return 0 ;
295
+ }
296
+
321
297
result_t Stat::isDirectory (bool & retVal)
322
298
{
323
- retVal = m_isDirectory;
299
+ retVal = (S_IFDIR & m_mode) != 0 ;
300
+
301
+ return 0 ;
302
+ }
303
+
304
+ result_t Stat::isFIFO (bool & retVal)
305
+ {
306
+ #ifdef _WIN32
307
+ retVal = false ;
308
+ #else
309
+ retVal = S_ISFIFO (m_mode);
310
+ #endif
311
+
324
312
return 0 ;
325
313
}
326
314
327
315
result_t Stat::isFile (bool & retVal)
328
316
{
329
- retVal = m_isFile;
317
+ retVal = (S_IFREG & m_mode) != 0 ;
318
+
330
319
return 0 ;
331
320
}
332
321
333
322
result_t Stat::isSymbolicLink (bool & retVal)
334
323
{
335
- retVal = m_isSymbolicLink;
324
+ retVal = S_ISLNK (m_mode);
325
+
336
326
return 0 ;
337
327
}
338
328
339
329
result_t Stat::isMemory (bool & retVal)
340
330
{
341
331
retVal = m_isMemory;
332
+
342
333
return 0 ;
343
334
}
344
335
345
336
result_t Stat::isSocket (bool & retVal)
346
337
{
347
338
retVal = m_isSocket;
339
+
348
340
return 0 ;
349
341
}
350
342
}
0 commit comments