Fixed opening of paths with on Latin chars. Fixed All PNGs saving.

This commit is contained in:
meffi@lab313.ru
2014-04-16 23:44:19 +00:00
parent db601dcd85
commit 180cf642d6
8 changed files with 128 additions and 116 deletions

View File

@@ -118,20 +118,7 @@
<OtherUnitFiles Value="bgrabitmap"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<RelocatableUnit Value="True"/>
<TargetCPU Value="x86_64"/>
<TargetOS Value="linux"/>
<Optimizations>
<OptimizationLevel Value="3"/>
</Optimizations>
</CodeGeneration>
<Linking>
<Debugging>
<GenerateDebugInfo Value="False"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>

View File

@@ -12,7 +12,7 @@
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="37" Y="11"/>
<UsageCount Value="46"/>
<UsageCount Value="47"/>
</Unit0>
<Unit1>
<Filename Value="umain.pas"/>
@@ -23,9 +23,9 @@
<UnitName Value="umain"/>
<EditorIndex Value="0"/>
<WindowIndex Value="0"/>
<TopLine Value="718"/>
<CursorPos X="27" Y="736"/>
<UsageCount Value="46"/>
<TopLine Value="940"/>
<CursorPos X="85" Y="952"/>
<UsageCount Value="47"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
@@ -36,7 +36,7 @@
<WindowIndex Value="0"/>
<TopLine Value="42"/>
<CursorPos X="88" Y="20"/>
<UsageCount Value="46"/>
<UsageCount Value="47"/>
</Unit2>
<Unit3>
<Filename Value="ecc.pas"/>
@@ -45,37 +45,41 @@
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="6" Y="11"/>
<UsageCount Value="46"/>
<UsageCount Value="47"/>
</Unit3>
<Unit4>
<Filename Value="ucommon.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ucommon"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="2"/>
<EditorIndex Value="5"/>
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="35" Y="6"/>
<UsageCount Value="46"/>
<UsageCount Value="47"/>
<Loaded Value="True"/>
</Unit4>
<Unit5>
<Filename Value="utim.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="utim"/>
<EditorIndex Value="2"/>
<WindowIndex Value="0"/>
<TopLine Value="165"/>
<CursorPos X="85" Y="179"/>
<UsageCount Value="46"/>
<TopLine Value="442"/>
<CursorPos X="3" Y="456"/>
<UsageCount Value="47"/>
<Loaded Value="True"/>
</Unit5>
<Unit6>
<Filename Value="ucdimage.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ucdimage"/>
<EditorIndex Value="3"/>
<WindowIndex Value="0"/>
<TopLine Value="12"/>
<CursorPos X="11" Y="37"/>
<UsageCount Value="46"/>
<TopLine Value="70"/>
<CursorPos X="65" Y="78"/>
<UsageCount Value="47"/>
<Loaded Value="True"/>
</Unit6>
<Unit7>
<Filename Value="usettings.pas"/>
@@ -84,7 +88,7 @@
<WindowIndex Value="0"/>
<TopLine Value="52"/>
<CursorPos X="87" Y="71"/>
<UsageCount Value="46"/>
<UsageCount Value="47"/>
</Unit7>
<Unit8>
<Filename Value="uscanresult.pas"/>
@@ -93,38 +97,40 @@
<WindowIndex Value="0"/>
<TopLine Value="26"/>
<CursorPos X="1" Y="66"/>
<UsageCount Value="45"/>
<UsageCount Value="46"/>
</Unit8>
<Unit9>
<Filename Value="uscanthread.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="uscanthread"/>
<EditorIndex Value="1"/>
<EditorIndex Value="4"/>
<WindowIndex Value="0"/>
<TopLine Value="41"/>
<CursorPos X="54" Y="62"/>
<UsageCount Value="45"/>
<TopLine Value="1"/>
<CursorPos X="78" Y="20"/>
<UsageCount Value="46"/>
<Loaded Value="True"/>
</Unit9>
<Unit10>
<Filename Value="ucpucount.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ucpucount"/>
<EditorIndex Value="3"/>
<EditorIndex Value="6"/>
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="23" Y="8"/>
<UsageCount Value="44"/>
<UsageCount Value="45"/>
<Loaded Value="True"/>
</Unit10>
<Unit11>
<Filename Value="udrawtim.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="udrawtim"/>
<EditorIndex Value="1"/>
<WindowIndex Value="0"/>
<TopLine Value="187"/>
<CursorPos X="35" Y="203"/>
<UsageCount Value="31"/>
<TopLine Value="110"/>
<CursorPos X="1" Y="127"/>
<UsageCount Value="32"/>
<Loaded Value="True"/>
</Unit11>
<Unit12>
<Filename Value="bgrabitmap\bgrabitmap.pas"/>
@@ -133,7 +139,7 @@
<WindowIndex Value="0"/>
<TopLine Value="55"/>
<CursorPos X="3" Y="69"/>
<UsageCount Value="21"/>
<UsageCount Value="22"/>
</Unit12>
<Unit13>
<Filename Value="l2sq_table.pas"/>
@@ -357,99 +363,127 @@
<General>
<ActiveWindowIndexAtStart Value="0"/>
</General>
<JumpHistory Count="23" HistoryIndex="22">
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="umain.pas"/>
<Caret Line="876" Column="31" TopLine="861"/>
<Caret Line="390" Column="1" TopLine="373"/>
</Position1>
<Position2>
<Filename Value="umain.pas"/>
<Caret Line="888" Column="26" TopLine="879"/>
<Caret Line="391" Column="1" TopLine="373"/>
</Position2>
<Position3>
<Filename Value="umain.pas"/>
<Caret Line="894" Column="32" TopLine="880"/>
<Caret Line="393" Column="1" TopLine="377"/>
</Position3>
<Position4>
<Filename Value="umain.pas"/>
<Caret Line="897" Column="9" TopLine="883"/>
<Caret Line="394" Column="1" TopLine="377"/>
</Position4>
<Position5>
<Filename Value="umain.pas"/>
<Caret Line="894" Column="1" TopLine="883"/>
<Caret Line="395" Column="1" TopLine="377"/>
</Position5>
<Position6>
<Filename Value="umain.pas"/>
<Caret Line="894" Column="1" TopLine="883"/>
<Caret Line="396" Column="1" TopLine="377"/>
</Position6>
<Position7>
<Filename Value="umain.pas"/>
<Caret Line="895" Column="1" TopLine="883"/>
<Caret Line="398" Column="1" TopLine="383"/>
</Position7>
<Position8>
<Filename Value="umain.pas"/>
<Caret Line="894" Column="59" TopLine="883"/>
<Caret Line="399" Column="1" TopLine="383"/>
</Position8>
<Position9>
<Filename Value="umain.pas"/>
<Caret Line="896" Column="23" TopLine="883"/>
<Caret Line="400" Column="1" TopLine="383"/>
</Position9>
<Position10>
<Filename Value="umain.pas"/>
<Caret Line="883" Column="47" TopLine="871"/>
<Caret Line="401" Column="1" TopLine="383"/>
</Position10>
<Position11>
<Filename Value="umain.pas"/>
<Caret Line="204" Column="30" TopLine="192"/>
<Caret Line="403" Column="75" TopLine="383"/>
</Position11>
<Position12>
<Filename Value="umain.pas"/>
<Caret Line="131" Column="21" TopLine="117"/>
<Caret Line="404" Column="9" TopLine="383"/>
</Position12>
<Position13>
<Filename Value="umain.pas"/>
<Caret Line="518" Column="1" TopLine="504"/>
<Caret Line="382" Column="1" TopLine="367"/>
</Position13>
<Position14>
<Filename Value="umain.pas"/>
<Caret Line="519" Column="1" TopLine="504"/>
<Caret Line="404" Column="1" TopLine="391"/>
</Position14>
<Position15>
<Filename Value="umain.pas"/>
<Caret Line="892" Column="41" TopLine="875"/>
<Filename Value="udrawtim.pas"/>
<Caret Line="122" Column="1" TopLine="107"/>
</Position15>
<Position16>
<Filename Value="umain.pas"/>
<Caret Line="519" Column="1" TopLine="504"/>
<Filename Value="udrawtim.pas"/>
<Caret Line="123" Column="1" TopLine="107"/>
</Position16>
<Position17>
<Filename Value="umain.pas"/>
<Caret Line="871" Column="41" TopLine="862"/>
<Caret Line="404" Column="1" TopLine="385"/>
</Position17>
<Position18>
<Filename Value="ucommon.pas"/>
<Caret Line="6" Column="50" TopLine="1"/>
<Filename Value="udrawtim.pas"/>
<Caret Line="125" Column="1" TopLine="110"/>
</Position18>
<Position19>
<Filename Value="umain.pas"/>
<Caret Line="524" Column="48" TopLine="516"/>
<Filename Value="udrawtim.pas"/>
<Caret Line="127" Column="1" TopLine="110"/>
</Position19>
<Position20>
<Filename Value="umain.pas"/>
<Caret Line="468" Column="104" TopLine="455"/>
<Caret Line="396" Column="73" TopLine="385"/>
</Position20>
<Position21>
<Filename Value="umain.pas"/>
<Caret Line="704" Column="37" TopLine="695"/>
<Caret Line="404" Column="1" TopLine="385"/>
</Position21>
<Position22>
<Filename Value="umain.pas"/>
<Caret Line="736" Column="83" TopLine="718"/>
<Filename Value="udrawtim.pas"/>
<Caret Line="122" Column="1" TopLine="110"/>
</Position22>
<Position23>
<Filename Value="uscanthread.pas"/>
<Caret Line="197" Column="22" TopLine="173"/>
<Filename Value="udrawtim.pas"/>
<Caret Line="123" Column="1" TopLine="110"/>
</Position23>
<Position24>
<Filename Value="umain.pas"/>
<Caret Line="388" Column="17" TopLine="385"/>
</Position24>
<Position25>
<Filename Value="umain.pas"/>
<Caret Line="405" Column="1" TopLine="385"/>
</Position25>
<Position26>
<Filename Value="udrawtim.pas"/>
<Caret Line="122" Column="1" TopLine="110"/>
</Position26>
<Position27>
<Filename Value="udrawtim.pas"/>
<Caret Line="123" Column="1" TopLine="110"/>
</Position27>
<Position28>
<Filename Value="udrawtim.pas"/>
<Caret Line="125" Column="1" TopLine="110"/>
</Position28>
<Position29>
<Filename Value="udrawtim.pas"/>
<Caret Line="127" Column="1" TopLine="110"/>
</Position29>
<Position30>
<Filename Value="umain.pas"/>
<Caret Line="394" Column="94" TopLine="385"/>
</Position30>
</JumpHistory>
</ProjectSession>
<EditorMacros Count="0"/>

View File

@@ -40,7 +40,7 @@ procedure ReplaceTimInFileFromMemory(const FileName: string; TIM: PTIM;
implementation
uses
ucommon, ecc, edc, classes, FileUtil, sysutils;
ucommon, ecc, edc, classes, FileUtil, sysutils, lazutf8classes;
function bin2bcd(P: Integer): byte;
begin
@@ -69,7 +69,7 @@ const
var
Sz: cardinal;
pFile: PBytesArray;
tmp: TFileStream;
tmp: TFileStreamUTF8;
begin
Result := False;
Sz := FileSize(FileName);
@@ -80,7 +80,7 @@ begin
pFile := GetMemory(cSectorHeaderSize);
try
tmp := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
tmp := TFileStreamUTF8.Create(FileName, fmOpenRead or fmShareDenyWrite);
tmp.Read(pFile^[0], cSectorHeaderSize);
Result := ((Sz mod cSectorSize) = 0) and (CompareMem(@cSectorHeader, pFile, cSectorHeaderSize));
finally
@@ -94,7 +94,7 @@ procedure ReplaceTimInFileFromMemory(const FileName: string; TIM: PTIM;
type
TSecAddrAndMode = array [0 .. cSectorAddressSize + cSectorModeSize - 1] of byte;
var
sImageStream: TFileStream;
sImageStream: TFileStreamUTF8;
TimOffsetInSector, FirstPartSize, LastPartSize: Integer;
TimSectorNumber, TimStartSectorPos: Integer;
Sector: TCDSector;
@@ -102,8 +102,7 @@ var
P, TIM_FULL_SECTORS: Integer;
SecAddrAndMode: TSecAddrAndMode;
begin
sImageStream := TFileStream.Create(FileName, fmOpenReadWrite or
fmShareDenyWrite);
sImageStream := TFileStreamUTF8.Create(FileName, fmOpenReadWrite or fmShareDenyWrite);
if not ImageScan then
begin

View File

@@ -3,7 +3,7 @@ unit ucommon;
interface
const
cProgramName = 'Tim2View SVN.r61 by [Lab 313] (for ' +
cProgramName = 'Tim2View SVN.r62 by [Lab 313] (for ' +
{$IFDEF Linux}'Linux' + {$IFEND}
{$IFDEF Darwin}'Mac OS X' + {$IFEND}
{$IFDEF Windows}'Windows' + {$IFEND}
@@ -29,7 +29,6 @@ type
TBytesArray = array [0 .. cMaxFileSize - 1] of byte;
PBytesArray = ^TBytesArray;
function ExtractJustName(const Path: string): string;
function Min(A, B: Integer): Integer;
function Max(A, B: Integer): Integer;
@@ -53,10 +52,4 @@ begin
Result := B;
end;
function ExtractJustName(const Path: string): string;
begin
Result := ExtractFileName(Path);
Result := Copy(Result, 1, Length(Result) - Length(ExtractFileExt(Result)));
end;
end.

View File

@@ -122,7 +122,7 @@ begin
RW := GetTimRealWidth(TIM);
RH := GetTimHeight(TIM);
if Surf^ <> nil then Surf^.Free;
if (Surf^ <> nil) then Surf^.Free;
Surf^ := TBGRABitmap.Create(RW, RH);

View File

@@ -204,7 +204,7 @@ begin
if not dlgSavePNG.Execute then Exit;
Surf^.SaveToFile(dlgSavePNG.FileName);
Surf^.SaveToFileUTF8(dlgSavePNG.FileName);
end;
procedure TfrmMain.actTimInfoExecute(Sender: TObject);
@@ -314,10 +314,10 @@ begin
reg.WriteString('', 'Tim File Format');
reg.CloseKey;
reg.OpenKey('Software\Classes\TimFile\DefaultIcon', True);
reg.WriteString('', '"' + ParamStr(0) +'",0');
reg.WriteString('', '"' + ParamStrUTF8(0) +'",0');
reg.CloseKey;
reg.OpenKey('Software\Classes\TimFile\shell\Open\Command', True);
reg.WriteString('', '"' + ParamStr(0) + '" "%1"');
reg.WriteString('', '"' + ParamStrUTF8(0) + '" "%1"');
reg.CloseKey;
finally
reg.Free;
@@ -385,6 +385,7 @@ begin
IsImage := SelectedScanResult.IsImage;
New(Surf_);
Surf_^ := nil;
pbProgress.Position := 0;
pbProgress.Max := SelectedScanResult.Count;
@@ -395,16 +396,17 @@ begin
SIZE := ScanTim.Size;
BIT_MODE := ScanTim.BitMode;
Path := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0)) + cExtractedPngsDir);
CreateDir(Path);
Path := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStrUTF8(0)) + cExtractedPngsDir);
CreateDirUTF8(Path);
Path := IncludeTrailingPathDelimiter(Path + ExtractFileName(FName));
CreateDir(Path);
CreateDirUTF8(Path);
TIM := LoadTimFromFile(FName, OFFSET, IsImage, SIZE);
TimToPNG(TIM, cbbCLUT.ItemIndex, Surf_, cbbTranspMode.ItemIndex);
Surf_^.SaveToFile(Path + FormatPngName(FName, I - 1, BIT_MODE, 0));
Surf_^.SaveToFileUTF8(Path + FormatPngName(FName, I - 1, BIT_MODE, 0));
Surf_^.Free;
Surf_^ := nil;
FreeTIM(TIM);
@@ -451,10 +453,10 @@ begin
SIZE := ScanTim.Size;
BIT_MODE := ScanTim.BitMode;
Path := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0)) + cExtractedTimsDir);
CreateDir(Path);
Path := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStrUTF8(0)) + cExtractedTimsDir);
CreateDirUTF8(Path);
Path := IncludeTrailingPathDelimiter(Path + ExtractFileName(FName));
CreateDir(Path);
CreateDirUTF8(Path);
TIM := LoadTimFromFile(FName, OFFSET, IsImage, SIZE);
SaveTimToFile(Path + FormatTimName(FName, I - 1, BIT_MODE), TIM);
@@ -528,7 +530,7 @@ var
begin
{$IFnDEF Windows}mnOptions.Enabled := False;{$IFEND}
Settings := TSettings.Create(ExtractFilePath(ParamStr(0)));
Settings := TSettings.Create(ExtractFilePath(ParamStrUTF8(0)));
actStretch.Checked := Settings.StretchMode;
cbbTranspMode.ItemIndex := Settings.TranspMode;
@@ -552,7 +554,7 @@ begin
CheckButtonsAndMainMenu;
if ParamCount > 0 then ScanPath(ParamStr(1));
if ParamCount > 0 then ScanPath(ParamStrUTF8(1));
end;
procedure TfrmMain.FormDropFiles(Sender: TObject;
@@ -722,7 +724,7 @@ begin
btnStopScan.Enabled := True;
btnStopScan.Tag := NativeInt(False);
if FileExists(Path) then
if FileExistsUTF8(Path) then
ScanFile(Path)
else
ScanDirectory(Path);
@@ -762,7 +764,7 @@ var
Dir: string;
begin
Dir := IncludeTrailingPathDelimiter(Directory);
isFound := FindFirst(Dir + '*', faAnyFile, sRec) = 0;
isFound := FindFirstUTF8(Dir + '*', faAnyFile, sRec) = 0;
while isFound do
begin
if (sRec.Name <> '.') and (sRec.Name <> '..') then
@@ -773,9 +775,9 @@ begin
ScanFile(Dir + sRec.Name);
end;
Application.ProcessMessages;
isFound := FindNext(sRec) = 0;
isFound := FindNextUTF8(sRec) = 0;
end;
FindClose(sRec);
FindCloseUTF8(sRec);
end;
procedure TfrmMain.CheckButtonsAndMainMenu;
@@ -949,13 +951,13 @@ end;
function TfrmMain.FormatTimName(const FileName: string; ListIdx_,
BitMode: Integer): string;
begin
Result := Format(cAutoExtractionTimFormat, [ExtractJustName(FileName), ListIdx_ + 1, BitMode]);
Result := Format(cAutoExtractionTimFormat, [ExtractFileNameWithoutExt(FileName), ListIdx_ + 1, BitMode]);
end;
function TfrmMain.FormatPngName(const FileName: string; ListIdx_, BitMode,
Clut: Integer): string;
begin
Result := Format(cAutoExtractionPngFormat, [ExtractJustName(FileName), ListIdx_ + 1, BitMode, Clut + 1]);
Result := Format(cAutoExtractionPngFormat, [ExtractFileNameWithoutExt(FileName), ListIdx_ + 1, BitMode, Clut + 1]);
end;
procedure TfrmMain.ShowTim;

View File

@@ -3,7 +3,7 @@ unit uscanthread;
interface
uses
ucommon, utim, uscanresult, classes, fgl;
ucommon, utim, uscanresult, classes, fgl, lazutf8classes;
type
TScanThread = class(TThread)
@@ -16,7 +16,7 @@ type
pClearBufferPosition: Integer;
pClearBufferSize: Integer;
pSectorBufferSize: Integer;
pSrcFileStream: TFileStream;
pSrcFileStream: TFileStreamUTF8;
pStopScan: boolean;
procedure SetStatusText;
procedure StartScan;
@@ -39,8 +39,7 @@ uses
umain, ucdimage, sysutils, FileUtil;
const
cClearBufferSize = ((cTIMMaxSize div cSectorDataSize) + 1) *
cSectorDataSize * 2;
cClearBufferSize = ((cTIMMaxSize div cSectorDataSize) + 1) * cSectorDataSize * 2;
cSectorBufferSize = (cClearBufferSize div cSectorDataSize) * cSectorSize;
{ TScanThread }
@@ -101,8 +100,7 @@ begin
SectorBuffer := GetMemory(pSectorBufferSize);
ClearBuffer := GetMemory(pClearBufferSize);
pSrcFileStream := TFileStream.Create(pScanResult.ScanFile, fmOpenRead or
fmShareDenyWrite);
pSrcFileStream := TFileStreamUTF8.Create(pScanResult.ScanFile, fmOpenRead or fmShareDenyWrite);
pSrcFileStream.Position := 0;

View File

@@ -145,7 +145,7 @@ function ConvertCLUTColor(COLOR: TCLUT_COLOR): word;
implementation
uses
ucdimage, classes, sysutils;
ucdimage, classes, sysutils, lazutf8classes;
function ConvertTIMColor(COLOR: word): TCLUT_COLOR;
begin
@@ -366,12 +366,12 @@ var
TimOffsetInSector, FirstPartSize, LastPartSize: Integer;
TimSectorNumber, TimStartSectorPos: Integer;
TIM_BUF: PTIMDataArray;
sImageStream: TFileStream;
sImageStream: TFileStreamUTF8;
Sector: TCDSector;
P, TIM_FULL_SECTORS: Integer;
begin
try
sImageStream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
sImageStream := TFileStreamUTF8.Create(FileName, fmOpenRead or fmShareDenyWrite);
TimSectorNumber := Position div cSectorSize + 1;
TimOffsetInSector := Position mod cSectorSize - cSectorInfoSize;
@@ -451,12 +451,12 @@ end;
function LoadTimFromFile(const FileName: string; var Position: Integer;
ImageScan: Boolean; dwSize: Integer): PTIM;
var
sTIM: TFileStream;
sTIM: TFileStreamUTF8;
begin
if not ImageScan then
begin
try
sTIM := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
sTIM := TFileStreamUTF8.Create(FileName, fmOpenRead or fmShareDenyWrite);
Result := LoadTimFromStream(sTIM, Position, dwSize);
finally
sTIM.Free;
@@ -469,13 +469,12 @@ end;
procedure SaveTimToFile(const FileName: string; TIM: PTIM);
var
tmp: TMemoryStream;
tmp: TFileStreamUTF8;
begin
if TIM = nil then Exit;
tmp := TMemoryStream.Create;
tmp := TFileStreamUTF8.Create(FileName, fmOpenWrite or fmCreate, fmShareDenyRead);
tmp.Write(TIM^.DATA^[0], TIM^.dwSize);
tmp.SaveToFile(FileName);
tmp.Free;
end;