mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
FIX: Setting attributes under Windows
This commit is contained in:
parent
fdbc9626c9
commit
89fd87fa7e
1 changed files with 20 additions and 3 deletions
23
uOSUtils.pas
23
uOSUtils.pas
|
|
@ -197,7 +197,8 @@ function mbFileCreate(const FileName: UTF8String; Mode: Integer): Integer;overlo
|
|||
function mbFileAge(const FileName: UTF8String): Longint;
|
||||
function mbFileExists(const FileName: UTF8String): Boolean;
|
||||
function mbDirectoryExists(const Directory : UTF8String) : Boolean;
|
||||
function mbFileGetAttr(const FileName: UTF8String): Longint;
|
||||
function mbFileGetAttr(const FileName: UTF8String): LongInt;
|
||||
function mbFileSetAttr (const FileName: UTF8String; Attr: LongInt) : LongInt;
|
||||
function mbDeleteFile(const FileName: UTF8String): Boolean;
|
||||
function mbRenameFile(const OldName, NewName : UTF8String): Boolean;
|
||||
function mbFileSize(const FileName: UTF8String): Int64;
|
||||
|
|
@ -269,7 +270,7 @@ var
|
|||
ft : TFileTime;
|
||||
Handle: THandle;
|
||||
begin
|
||||
iAttr := FileGetAttr(sSrc);
|
||||
iAttr := mbFileGetAttr(sSrc);
|
||||
//---------------------------------------------------------
|
||||
Handle:= mbFileOpen(sSrc, fmOpenRead or fmShareDenyNone);
|
||||
GetFileTime(Handle,nil,nil,@ft);
|
||||
|
|
@ -277,7 +278,7 @@ begin
|
|||
//---------------------------------------------------------
|
||||
if bDropReadOnlyFlag and Boolean(iAttr and faReadOnly) then
|
||||
iAttr := (iAttr and not faReadOnly);
|
||||
Result := (FileSetAttr(sDst, iAttr) = 0);
|
||||
Result := (mbFileSetAttr(sDst, iAttr) = 0);
|
||||
//---------------------------------------------------------
|
||||
Handle:= mbFileOpen(sDst, fmOpenReadWrite or fmShareExclusive);
|
||||
Result := SetFileTime(Handle, nil, nil, @ft);
|
||||
|
|
@ -1014,6 +1015,22 @@ begin
|
|||
end;
|
||||
{$ENDIF}
|
||||
|
||||
function mbFileSetAttr(const FileName: UTF8String; Attr: LongInt): LongInt;
|
||||
{$IFDEF MSWINDOWS}
|
||||
var
|
||||
wFileName: WideString;
|
||||
begin
|
||||
Result:= 0;
|
||||
wFileName:= UTF8Decode(FileName);
|
||||
if not SetFileAttributesW(PWChar(wFileName), Attr) then
|
||||
Result:= GetLastError;
|
||||
end;
|
||||
{$ELSE}
|
||||
begin
|
||||
Result:= -1;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
function mbDeleteFile(const FileName: UTF8String): Boolean;
|
||||
{$IFDEF MSWINDOWS}
|
||||
var
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue