ADD: Overlong path support in several functions

This commit is contained in:
Alexander Koblov 2016-08-20 15:03:55 +00:00
commit 8a489d59ea
3 changed files with 14 additions and 15 deletions

View file

@ -5,7 +5,7 @@ unit uFileSystemSetFilePropertyOperation;
interface
uses
LazUtf8,Classes, SysUtils,
Classes, SysUtils, LazUTF8,
uFileSourceSetFilePropertyOperation,
uFileSource,
uFileSourceOperationOptions,
@ -48,7 +48,7 @@ uses
uGlobs, uLng, DCDateTimeUtils, uFileSystemUtil,
uFileSourceOperationUI, DCOSUtils, DCStrUtils, DCBasicTypes
{$IF DEFINED(MSWINDOWS)}
, Windows, ShellAPI, LCLProc
, Windows, ShellAPI
{$ELSEIF DEFINED(UNIX)}
, BaseUnix, FileUtil
{$ENDIF}
@ -410,7 +410,7 @@ begin
{$ELSE}
if gUseShellForFileOperations then
if gUseShellForFileOperations and (UTF8Length(OldName) < MAX_PATH - 1) and (UTF8Length(NewName) < MAX_PATH - 1) then
begin
if ShellRename then
Result := sfprSuccess

View file

@ -145,7 +145,7 @@ implementation
uses
uDebug, uOSUtils, DCStrUtils, FileUtil, uFindEx, DCClassesUtf8, uFileProcs, uLng,
DCBasicTypes, uFileSource, uFileSystemFileSource, uFileProperty,
StrUtils, DCDateTimeUtils, uShowMsg, Forms;
StrUtils, DCDateTimeUtils, uShowMsg, Forms, LazUTF8;
function ApplyRenameMask(aFile: TFile; NameMask: String; ExtMask: String): String; overload;
begin
@ -848,13 +848,13 @@ begin
end;
// Check MAX_PATH
if Length(TargetName) > MAX_PATH - 1 then
if UTF8Length(TargetName) > MAX_PATH - 1 then
begin
if FMaxPathOption <> fsourInvalid then
AskResult := FMaxPathOption
else begin
AskResult := AskQuestion(Format(rsMsgFilePathOverMaxPath,
[Length(TargetName), MAX_PATH - 1, LineEnding + WrapTextSimple(TargetName, 100) + LineEnding]), '',
[UTF8Length(TargetName), MAX_PATH - 1, LineEnding + WrapTextSimple(TargetName, 100) + LineEnding]), '',
[fsourIgnore, fsourSkip, fsourAbort, fsourIgnoreAll, fsourSkipAll], fsourIgnore, fsourSkip);
end;
case AskResult of

View file

@ -136,7 +136,7 @@ implementation
uses
{$IF DEFINED(MSWINDOWS)}
Windows, DCFileAttributes, uMyWindows,
Windows, DCFileAttributes, DCWindows, uMyWindows,
{$ELSEIF DEFINED(UNIX)}
BaseUnix, FileUtil, uUsersGroups,
{$ENDIF}
@ -193,14 +193,13 @@ function GetFileInfo(const FileName: String; out FileInfo: TWin32FindDataW): Boo
var
Handle: System.THandle;
begin
Result:= False;
Handle := FindFirstFileW(PWideChar(UTF8Decode(FileName)), FileInfo);
if Handle <> INVALID_HANDLE_VALUE then
begin
FileInfo.dwFileAttributes:= ExtractFileAttributes(FileInfo);
Windows.FindClose(Handle);
Result:= True;
end;
Handle := FindFirstFileW(PWideChar(UTF16LongName(FileName)), FileInfo);
Result := Handle <> INVALID_HANDLE_VALUE;
if Result then
begin
FileInfo.dwFileAttributes:= ExtractFileAttributes(FileInfo);
Windows.FindClose(Handle);
end;
end;
{$ELSEIF DEFINED(UNIX)}
function GetFileInfo(const FileName: String; out FileInfo: BaseUnix.Stat): Boolean;