root/trunk/Units/unit_Globals.pas

474479
154
function ExecAndWait(const FileName, Params: string; const WinState: word): Boolean;
154
function ExecAndWait(const FileName, Params: string; const WinState: word): Boolean;
155
155
156
function CleanExtension(const Ext: string): string;
156
function CleanExtension(const Ext: string): string;
157
function ExtractShortFileName(const FileName: string): string;
158
157
159
function TestArchive(const FileName: string): Boolean;
158
function TestArchive(const FileName: string): Boolean;
160
159
...
...
325
  Forms,
324
  Forms,
326
  Windows,
325
  Windows,
327
  StrUtils,
326
  StrUtils,
327
  IOUtils,
328
  Character,
328
  unit_Settings,
329
  unit_Settings,
329
  unit_Consts,
330
  unit_Consts,
330
  ShlObj,
331
  ShlObj,
...
...
414
  if
415
  if
415
    ((L >= 1) and IsPathDelimiter(FileName, 1)) or // \dir\subdir or /dir/subdir
416
    ((L >= 1) and IsPathDelimiter(FileName, 1)) or // \dir\subdir or /dir/subdir
416
    ((L >= 2) and (FileName[1] in ['A' .. 'Z', 'a' .. 'z']) and (FileName[2] = ':')) // C:, D:, etc.
417
    ((L >= 2) and (FileName[1] in ['A' .. 'Z', 'a' .. 'z']) and (FileName[2] = ':')) // C:, D:, etc.
417
    then
418
  then
418
    Result := False;
419
    Result := False;
419
end;
420
end;
420
421
...
...
422
var
423
var
423
  FullPath: string;
424
  FullPath: string;
424
begin
425
begin
425
  if Path <> '\' then
426
  if Path = '\' then
426
  begin
427
  begin
427
    if Root = '' then
428
    Assert(False);
428
      Root := Settings.AppPath;
429
    FullPath := Root;
429
    FullPath := ExcludeTrailingPathDelimiter(
430
      IfThen(IsRelativePath(Path), IncludeTrailingPathDelimiter(Root) + Path, Path)
431
      );
432
  end
430
  end
433
  else
431
  else
434
    FullPath := ExcludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(Root));
432
  begin
433
    if Root = '' then
434
    begin
435
      Assert(False);
436
      Root := Settings.AppPath;
437
    end;
438
    FullPath := TPath.Combine(Root, Path);
439
  end;
440
435
  Result := SysUtils.ForceDirectories(FullPath);
441
  Result := SysUtils.ForceDirectories(FullPath);
436
end;
442
end;
437
443
...
...
567
  // фильтруем точки в конце имени
  if Length(conv) > 0 then
573
  // фильтруем точки в конце имени
  if Length(conv) > 0 then
568
    while conv[Length(conv)] = '.' do
574
    while conv[Length(conv)] = '.' do
569
      delete(conv, Length(conv), 1);
575
      Delete(conv, Length(conv), 1);
570
  Result := conv;
576
  Result := conv;
571
end;
577
end;
572
578
573
function GenerateBookLocation(const FullName: string): string;
579
function GenerateBookLocation(const FullName: string): string;
574
var
580
var
575
  Letter: string;
581
  Letter: Char;
576
  AuthorName: string;
582
  AuthorName: string;
577
begin
583
begin
578
  //
584
  //
...
...
581
  //
587
  //
582
  AuthorName := CheckSymbols(FullName); // Ф.И.О. - полностью!
588
  AuthorName := CheckSymbols(FullName); // Ф.И.О. - полностью!
583
589
584
  Letter := Trim(AuthorName[1]);
590
  Letter := AuthorName[1];
585
  if Letter = '' then
591
  if not IsLetterOrDigit(Letter) then
586
    Letter := '_';
592
    Letter := '_';
587
593
588
  AuthorName := Trim(AuthorName);
594
  AuthorName := Trim(AuthorName);
...
...
1022
  end;
1028
  end;
1023
end;
1029
end;
1024
1030
1025
function ExtractShortFileName(const FileName: string): string;
1026
var
1027
  Ext: string;
1028
begin
1029
  Ext := ExtractFileExt(FileName);
1030
  Result := Copy(FileName, 1, Length(FileName) - Length(Ext));
1031
end;
1032
1033
end.
1031
end.