瀏覽代碼

+ Added fileIsReadOnly

michael 21 年之前
父節點
當前提交
dc953332cd
共有 3 個文件被更改,包括 26 次插入3 次删除
  1. 5 1
      rtl/objpas/sysutils/filutilh.inc
  2. 10 1
      rtl/objpas/sysutils/sysutils.inc
  3. 11 1
      rtl/unix/sysutils.pp

+ 5 - 1
rtl/objpas/sysutils/filutilh.inc

@@ -78,11 +78,15 @@ Function FileSetAttr (Const Filename : String; Attr: longint) : Longint;
 Function DeleteFile (Const FileName : String) : Boolean;
 Function RenameFile (Const OldName, NewName : String) : Boolean;
 Function FileSearch (Const Name, DirList : String) : String;
+Function FileIsReadOnly(const FileName: String): Boolean; 
 
 
 {
   $Log$
-  Revision 1.1  2003-10-06 21:01:06  peter
+  Revision 1.2  2004-02-08 14:50:51  michael
+  + Added fileIsReadOnly
+
+  Revision 1.1  2003/10/06 21:01:06  peter
     * moved classes unit to rtl
 
   Revision 1.10  2003/04/01 15:57:41  peter

+ 10 - 1
rtl/objpas/sysutils/sysutils.inc

@@ -46,7 +46,16 @@
       until (length(temp)=0) or (length(result)<>0);
     end;
 
-      { Read String Handling functions implementation }
+  {$ifndef OS_FILEISREADONLY}
+  Function FileIsReadOnly(const FileName: String): Boolean; 
+  
+  begin
+    Result := (FileGetAttr(FileName) and faReadOnly) <> 0;
+  end;  
+  {$endif OS_FILEISREADONLY}
+  
+
+  { Read String Handling functions implementation }
   {$i sysstr.inc}
 
   { Read date & Time function implementations }

+ 11 - 1
rtl/unix/sysutils.pp

@@ -35,6 +35,8 @@ implementation
 
 Uses UnixUtil,Baseunix;
 
+{$Define OS_FILEISREADONLY} // Specific implementation for Unix.
+
 { Include platform independent implementation part }
 {$i sysutils.inc}
 
@@ -316,6 +318,11 @@ begin
   RenameFile:=BaseUnix.FpRename(OldNAme,NewName)>=0;
 end;
 
+Function FileIsReadOnly(const FileName: String): Boolean; 
+ 
+begin
+  Result := fpAccess(PChar(FileName),W_OK)= 0;
+end;  
 
 {****************************************************************************
                               Disk Functions
@@ -564,7 +571,10 @@ end.
 {
 
   $Log$
-  Revision 1.32  2004-02-08 11:01:17  michael
+  Revision 1.33  2004-02-08 14:50:51  michael
+  + Added fileIsReadOnly
+
+  Revision 1.32  2004/02/08 11:01:17  michael
   + Implemented getlastoserror
 
   Revision 1.31  2004/01/20 23:13:53  hajny