Skip to content

Commit

Permalink
Merge pull request #298 from pozitronik/issue_297
Browse files Browse the repository at this point in the history
Issue 297
  • Loading branch information
pozitronik authored Nov 18, 2023
2 parents 9f7fa6c + 10a050f commit 5aaa3e6
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 50 deletions.
2 changes: 1 addition & 1 deletion CloudMailRu.pas
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ function TCloudMailRu.getSharedFileUrl(remotePath: WideString; ShardType: WideSt
self.getShard(usedShard, ShardType);
if (self.public_account) then
exit(Format('%s%s%s', [IncludeSlash(usedShard), IncludeSlash(self.public_link), PathToUrl(remotePath, true, true)]));
if (ExtractRealPath(remotePath).isDir) then {для ссылок внутри каталогов перебираются файлы внутри «публичной ссылки» на каталог}
if (ExtractRealPath(remotePath).isDir = ID_Yes) then {для ссылок внутри каталогов перебираются файлы внутри «публичной ссылки» на каталог}
begin
result := Format('%s%s%s', [IncludeSlash(usedShard), self.public_link, PathToUrl(remotePath, true, true)]);
end else begin {для прямых ссылок берутся публичные ссылки файлов}
Expand Down
45 changes: 25 additions & 20 deletions MRC_Helper.pas
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,27 @@ interface

type

TIsDir = (ID_Yes, ID_No, ID_Unset);

TRealPath = record
account: WideString;
path: WideString;
isDir: boolean; //is directory
isDir: TIsDir; //is it a directory
upDirItem: boolean; //path/../
trashDir: boolean; //item is inside trash bin dir
sharedDir: boolean; //item is inside shared links dir
invitesDir: boolean; //item is inside invites dir
trashDir: boolean; //item is inside of a trash bin dir
sharedDir: boolean; //item is inside of a shared links dir
invitesDir: boolean; //item is inside of an invites dir
end;

function Implode(S: TStringList; Delimiter: WideString): WideString;
function Explode(S: WideString; Delimiter: char): TStringList;
function MyExtractStrings(Separators, WhiteSpace: TSysCharSet; Content: PWideChar; Strings: TStrings): integer;
function ExtractRealPath(VirtualPath: WideString): TRealPath;
function ExtractRealPath(VirtualPath: WideString; isDir: TIsDir = ID_Unset): TRealPath;
function ExtractVirtualPath(RealPath: TRealPath): WideString;
function inAccount(path: TRealPath; ignoreVirtual: boolean = true): boolean;
function SizeOfFile(const FileName: String): Int64;
function DateTimeToUnix(ConvDate: TDateTime): integer;
function CheckFlag(Check: Byte; Flags: integer): boolean; //Определяет, установлен ли указанный бит
function CheckFlag(Check: byte; Flags: integer): boolean; //Определяет, установлен ли указанный бит
function DateTimeToFileTime(FileTime: TDateTime): TFileTime;
procedure SetAllFileTime(const FileName: string; const FileTime: TFileTime);
procedure CenterWindow(WindowToStay, WindowToCenter: HWND);
Expand All @@ -59,7 +61,7 @@ function GetTmpFileName(Prefix: WideString = ''): WideString;
function ExtractCryptedFileNameFromPath(const FilePath: WideString): WideString;
function ExtractUniversalFilePath(const FileName: string): string;
function ExtractUniversalFileName(const FileName: string): string;
function ExtractUniversalFileExt(const FileName: string; TrimDot: boolean = false): string;
function ExtractUniversalFileExt(const FileName: string; TrimDot: boolean = False): string;
function ChangePathFileName(const FilePath, NewFileName: WideString): WideString;
function ChangeDecryptedPathFileName(const FilePath, NewFileName: WideString): WideString;
function CopyExt(FromFilename, ToFilename: WideString): WideString;
Expand Down Expand Up @@ -131,7 +133,7 @@ function MyExtractStrings(Separators, WhiteSpace: TSysCharSet; Content: PWideCha
if (Content = nil) or (Content^ = #0) or (Strings = nil) then
exit;
Tail := Content;
InQuote := false;
InQuote := False;
QuoteChar := #0;
Strings.BeginUpdate;
try
Expand Down Expand Up @@ -181,18 +183,21 @@ function MyExtractStrings(Separators, WhiteSpace: TSysCharSet; Content: PWideCha
end;
end;

function ExtractRealPath(VirtualPath: WideString): TRealPath;
function ExtractRealPath(VirtualPath: WideString; isDir: TIsDir = ID_Unset): TRealPath;
var
List: TStringList;
begin
Result.account := EmptyWideStr;
Result.path := EmptyWideStr;
//we can't rely on isDir property, cause it can't be clearly defined =(
Result.isDir := false;
Result.upDirItem := false;
Result.trashDir := false;
Result.sharedDir := false;
Result.invitesDir := false;
(*
we can't rely on isDir property, cause it can't be clearly determined from the path
therefore the property value can be passed as the parameter, when it is known.
*)
Result.isDir := isDir;
Result.upDirItem := False;
Result.trashDir := False;
Result.sharedDir := False;
Result.invitesDir := False;

if VirtualPath = EmptyWideStr then
exit; //root
Expand All @@ -205,13 +210,13 @@ function ExtractRealPath(VirtualPath: WideString): TRealPath;
Result.upDirItem := true;

if (List.Count > 0) and (List.Strings[List.Count - 1] = '\') then
Result.isDir := true;
Result.isDir := ID_Yes; // it newer happens, actually

if List.Count = 1 then
begin
Result.account := List.Strings[0];
if (Result.account = VirtualPath) then
Result.isDir := true;
Result.isDir := ID_Yes;

end else if (List.Count > 1) then
begin
Expand Down Expand Up @@ -257,7 +262,7 @@ function DateTimeToUnix(ConvDate: TDateTime): integer;
Result := Round((ConvDate - UnixStartDate) * 86400);
end;

function CheckFlag(Check: Byte; Flags: LongInt): boolean; //Определяет, установлен ли указанный бит
function CheckFlag(Check: byte; Flags: LongInt): boolean; //Определяет, установлен ли указанный бит
begin
Result := (Flags and Check) <> 0;
end;
Expand Down Expand Up @@ -445,7 +450,7 @@ function ExtractUniversalFileName(const FileName: string): string;
Result := FileName.Substring(I + 1);
end;

function ExtractUniversalFileExt(const FileName: string; TrimDot: boolean = false): string;
function ExtractUniversalFileExt(const FileName: string; TrimDot: boolean = False): string;
var
I: integer;
begin
Expand Down Expand Up @@ -745,7 +750,7 @@ function Run(path, ParamString, StartDir: WideString; SubstituteVariables: boole
else
lpCurrentDirectory := PWideChar(StartDir);

Result := CreateProcessW(nil, PWideChar(path + ' "' + ParamString + '"'), nil, nil, false, NORMAL_PRIORITY_CLASS, nil, lpCurrentDirectory, lpStartupInfo, lpProcessInformation);
Result := CreateProcessW(nil, PWideChar(path + ' "' + ParamString + '"'), nil, nil, False, NORMAL_PRIORITY_CLASS, nil, lpCurrentDirectory, lpStartupInfo, lpProcessInformation);
if Result then
with lpProcessInformation do
begin
Expand Down
Loading

0 comments on commit 5aaa3e6

Please sign in to comment.