the_Foundation [release-1.0]

FileInfo: Check if directory entries are writable

=> fde9e5efb2d2098453d8229ef87af5fa96156010

diff --git a/include/the_Foundation/fileinfo.h b/include/the_Foundation/fileinfo.h
index 08aa356..17ca697 100644
--- a/include/the_Foundation/fileinfo.h
+++ b/include/the_Foundation/fileinfo.h
@@ -47,6 +47,7 @@ iBool       exists_FileInfo         (const iFileInfo *);
 const iString * path_FileInfo       (const iFileInfo *);
 size_t      size_FileInfo           (const iFileInfo *);
 iBool       isDirectory_FileInfo    (const iFileInfo *);
+iBool       isWritable_FileInfo     (const iFileInfo *);
 iTime       lastModified_FileInfo   (const iFileInfo *);
 
 iBool       fileExists_FileInfo     (const iString *path);
diff --git a/src/fileinfo.c b/src/fileinfo.c
index b54ad5e..6d753db 100644
--- a/src/fileinfo.c
+++ b/src/fileinfo.c
@@ -68,6 +68,7 @@ static int access(const char *path, int mode) {
 enum FileInfoFlags {
     exists_FileInfoFlag     = iBit(1),
     directory_FileInfoFlag  = iBit(2),
+    writable_FileInfoFlag   = iBit(3),
 };
 
 struct Impl_FileInfo {
@@ -136,8 +137,10 @@ static iBool initDirEntry_FileInfo_(iFileInfo *d, const iString *dirPath, struct
     set_String(d->path, full);
     delete_String(full);
     deinit_String(&entryName);
-    
     d->flags = exists_FileInfoFlag;
+    if (access(cstr_String(d->path), W_OK) == 0) {
+        d->flags |= writable_FileInfoFlag;
+    }
 #if defined (iPlatformHaiku)
     struct stat s;
     stat(ent->d_name, &s);
@@ -176,6 +179,10 @@ size_t size_FileInfo(const iFileInfo *d) {
 iBool isDirectory_FileInfo(const iFileInfo *d) {
     return (d->flags & directory_FileInfoFlag) != 0;
 }
+    
+iBool isWritable_FileInfo(const iFileInfo *d) {
+    return (d->flags & writable_FileInfoFlag) != 0;
+}
 
 iTime lastModified_FileInfo(const iFileInfo *d) {
     if (!isValid_Time(&d->lastModified)) {
Proxy Information
Original URL
gemini://git.skyjake.fi/the_Foundation/release-1.0/cdiff/fde9e5efb2d2098453d8229ef87af5fa96156010
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
78.213525 milliseconds
Gemini-to-HTML Time
0.336455 milliseconds

This content has been proxied by September (ba2dc).