1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-12-22 15:28:50 -05:00

Fixed this unicode issue, I think.

This commit is contained in:
Raymond 2010-05-15 13:57:55 +02:00
parent 62bfea8be2
commit 4f6ad407e1
9 changed files with 44 additions and 39 deletions

View File

@ -46,7 +46,7 @@ uses
CastaliaSimplePasPar, v_AutoCompleteForm, PSDump; CastaliaSimplePasPar, v_AutoCompleteForm, PSDump;
const const
SimbaVersion = 668; SimbaVersion = 670;
type type
@ -1426,10 +1426,8 @@ begin
if (Paramcount = 1) and not (Application.HasOption('open')) then if (Paramcount = 1) and not (Application.HasOption('open')) then
begin begin
writeln('Opening file: ' + ParamStr(1)); writeln('Opening file: ' + ParamStr(1));
if FileExists(ParamStr(1)) then if FileExistsUTF8(ParamStrUTF8(1)) then
begin LoadScriptFile(ParamStrUTF8(1));
LoadScriptFile(paramstr(1));
end;
end else end else
// we have more parameters. Check for specific options. (-r -o, --run --open) // we have more parameters. Check for specific options. (-r -o, --run --open)
begin begin
@ -2819,7 +2817,7 @@ begin
Filter:= 'Simba Files|*.Simba;*.simb;*.cogat;*.mufa;*.txt;*.' +LoadSettingDef('Settings/Extensions/FileExtension','sex')+ Filter:= 'Simba Files|*.Simba;*.simb;*.cogat;*.mufa;*.txt;*.' +LoadSettingDef('Settings/Extensions/FileExtension','sex')+
'|Any files|*.*'; '|Any files|*.*';
if Execute then if Execute then
if FileExists(filename) then if FileExistsUTF8(filename) then
result := LoadScriptFile(filename); result := LoadScriptFile(filename);
finally finally
Free; Free;
@ -2841,7 +2839,7 @@ begin
CheckTabsFirst := True CheckTabsFirst := True
else else
CheckTabsFirst := (Lowercase(LoadSettingDef('Settings/Tabs/CheckTabsBeforeOpen','True')) = 'true'); CheckTabsFirst := (Lowercase(LoadSettingDef('Settings/Tabs/CheckTabsBeforeOpen','True')) = 'true');
if FileExists(FileName) then if FileExistsUTF8(FileName) then
begin; begin;
if CheckTabsFirst then if CheckTabsFirst then
begin; begin;
@ -2857,7 +2855,7 @@ begin
with CurrScript do with CurrScript do
begin begin
filename := SetDirSeparators(filename); filename := SetDirSeparators(filename);
SynEdit.Lines.LoadFromFile(FileName); SynEdit.Lines.LoadFromFile(filename);
StartText := SynEdit.Lines.text; StartText := SynEdit.Lines.text;
ScriptName:= ExtractFileNameOnly(filename); ScriptName:= ExtractFileNameOnly(filename);
mDebugLn('Script name will be: ' + ScriptName); mDebugLn('Script name will be: ' + ScriptName);

View File

@ -70,20 +70,20 @@ begin
end; end;
function ps_FileExists ( const FileName : string ) : Boolean;extdecl; function ps_FileExists ( const FileName : string ) : Boolean;extdecl;
begin begin
result := FileExists(FileName); result := FileExistsUTF8(FileName);
end; end;
function ps_DirectoryExists ( const DirectoryName : string ) : Boolean; extdecl; function ps_DirectoryExists ( const DirectoryName : string ) : Boolean; extdecl;
begin begin
result := DirectoryExists(DirectoryName); result := DirectoryExistsUTF8(DirectoryName);
end; end;
function ps_CreateDirectory( const DirectoryName : string) : boolean; extdecl; function ps_CreateDirectory( const DirectoryName : string) : boolean; extdecl;
begin begin
result := CreateDir(directoryName); result := CreateDirUTF8(directoryName);
end; end;
function ps_ForceDirectores(const dir : string) : boolean; extdecl; function ps_ForceDirectores(const dir : string) : boolean; extdecl;
begin begin
result := ForceDirectories(dir); result := ForceDirectoriesUTF8(dir);
end; end;
function ps_GetFiles(const Path, Ext : string) : TStringArray;extdecl; function ps_GetFiles(const Path, Ext : string) : TStringArray;extdecl;
@ -100,7 +100,7 @@ procedure ps_WriteINI(const Section, KeyName, NewString, FileName: string);extde
var var
tempini : TIniFile; tempini : TIniFile;
begin; begin;
tempini := TIniFile.Create(FileName,True); tempini := TIniFile.Create(UTF8ToSys(FileName),True);
tempini.WriteString(Section,keyname,newstring); tempini.WriteString(Section,keyname,newstring);
tempini.free; tempini.free;
end; end;
@ -109,7 +109,7 @@ function ps_ReadINI(const Section, KeyName, FileName: string): string;extdecl;
var var
tempini : TIniFile; tempini : TIniFile;
begin; begin;
tempini := TIniFile.Create(FileName,True); tempini := TIniFile.Create(UTF8ToSys(FileName),True);
Result := tempini.ReadString(section,keyname,''); Result := tempini.ReadString(section,keyname,'');
tempini.free; tempini.free;
end; end;
@ -118,7 +118,7 @@ procedure ps_DeleteINI(const Section, KeyName, FileName: string); extdecl;
var var
tempini : TIniFile; tempini : TIniFile;
begin; begin;
tempini := TIniFile.Create(FileName,True); tempini := TIniFile.Create(utf8tosys(FileName),True);
if KeyName = '' then if KeyName = '' then
tempini.EraseSection(Section) tempini.EraseSection(Section)
else else

View File

@ -53,6 +53,9 @@ type
implementation implementation
uses
FileUtil;
function DecompressBZip2(const input: TStream; const BlockSize: Cardinal): TMemoryStream; function DecompressBZip2(const input: TStream; const BlockSize: Cardinal): TMemoryStream;
var var
Unzipper : TDecompressBzip2Stream; Unzipper : TDecompressBzip2Stream;
@ -128,10 +131,10 @@ begin;
end; end;
end else if (DirRec.FileType = ftNormal) then end else if (DirRec.FileType = ftNormal) then
begin; begin;
if FileExists(outputdir + dirrec.name) and not overwrite then if FileExistsUTF8(outputdir + dirrec.name) and not overwrite then
continue; continue;
try try
FS := TFileStream.Create(outputdir +dirrec.name,fmCreate); FS := TFileStream.Create(UTF8ToSys(outputdir +dirrec.name),fmCreate);
tar.ReadFile(fs); tar.ReadFile(fs);
FS.Free; FS.Free;
except except

View File

@ -220,6 +220,7 @@ uses
math, //Maths! math, //Maths!
mmath, //Real maths! mmath, //Real maths!
strutils, strutils,
fileutil,
tpa, //Tpa stuff tpa, //Tpa stuff
forms,//Forms forms,//Forms
SynRegExpr, SynRegExpr,
@ -406,7 +407,7 @@ begin
Includes.Add(path); Includes.Add(path);
try try
f:= TFileStream.Create(Path, fmOpenRead or fmShareDenyWrite); f:= TFileStream.Create(UTF8ToSys(Path), fmOpenRead or fmShareDenyWrite);
SetLength(contents, f.Size); SetLength(contents, f.Size);
f.Read(contents[1], Length(contents)); f.Read(contents[1], Length(contents));
result:= true; result:= true;

View File

@ -95,7 +95,7 @@ type
implementation implementation
uses uses
stringutil; stringutil,fileutil;
constructor TSettingData.Create; constructor TSettingData.Create;
begin begin
@ -595,13 +595,13 @@ var
Doc: TXMLDocument; Doc: TXMLDocument;
begin begin
Nodes.Clear; Nodes.Clear;
if not fileExists(fileName) then if not fileExistsUTF8(fileName) then
begin begin
mDebugLn('SettingsFile hasn''t been created yet.'); mDebugLn('SettingsFile hasn''t been created yet.');
// create file. // create file.
SaveToXML(fileName); SaveToXML(fileName);
end; end;
ReadXMLFile(Doc, fileName); ReadXMLFile(Doc, utf8tosys(fileName));
InternalLoadFromXML(Doc); InternalLoadFromXML(Doc);
Doc.Free; Doc.Free;
end; end;
@ -667,7 +667,7 @@ begin
end; end;
try try
WriteXMLFile(XMLDoc, fileName); WriteXMLFile(XMLDoc, utf8tosys(fileName));
except except
mDebugLn('Failed to write ' + fileName); mDebugLn('Failed to write ' + fileName);
end; end;

View File

@ -86,6 +86,9 @@ type
implementation implementation
uses
FileUtil;
procedure TMMLFileDownloader.SetBasePath(s: string); procedure TMMLFileDownloader.SetBasePath(s: string);
begin begin
@ -164,7 +167,7 @@ begin
if FileURL = '' then if FileURL = '' then
raise Exception.Create('FileURL not set'); raise Exception.Create('FileURL not set');
Response := TFileStream.Create(FBasePath + FReplacementFile + '_', fmCreate); Response := TFileStream.Create(UTF8ToSys(FBasePath + FReplacementFile + '_'), fmCreate);
try try
Result := HTTPSend.HTTPMethod('GET', FileURL); Result := HTTPSend.HTTPMethod('GET', FileURL);
@ -199,21 +202,21 @@ begin
exit(False); exit(False);
//raise Exception.Create('ReplacementFile not set'); //raise Exception.Create('ReplacementFile not set');
end; end;
if not FileExists(FBasePath + FReplacementFile) then if not fileExistsUTF8(FBasePath + FReplacementFile) then
begin begin
mDebugLn('ReplacementFile not found'); mDebugLn('ReplacementFile not found');
exit(False); exit(False);
//raise Exception.Create('ReplacementFile not found'); //raise Exception.Create('ReplacementFile not found');
end; end;
if not FileExists(FBasePath + FReplacementFile+ '_') then if not fileExistsUTF8(FBasePath + FReplacementFile+ '_') then
begin begin
mDebugLn('ReplacementFile + _ not found'); mDebugLn('ReplacementFile + _ not found');
exit(False); exit(False);
//raise Exception.Create('ReplacementFile + _ not found'); //raise Exception.Create('ReplacementFile + _ not found');
end; end;
RenameFile(FBasePath + FReplacementFile, FBasePath + FReplacementFile+'_old_'); RenameFileUTF8(FBasePath + FReplacementFile, FBasePath + FReplacementFile+'_old_');
RenameFile(FBasePath + FReplacementFile +'_', FBasePath + FReplacementFile); RenameFileUTF8(FBasePath + FReplacementFile +'_', FBasePath + FReplacementFile);
DeleteFile(FBasePath + FReplacementFile+'_old_'); DeleteFileUTF8(FBasePath + FReplacementFile+'_old_');
{$IFDEF LINUX} {$IFDEF LINUX}
fpchmod(FBasePath + FReplacementFile, S_IRUSR or S_IWUSR or S_IXUSR or S_IRGRP fpchmod(FBasePath + FReplacementFile, S_IRUSR or S_IWUSR or S_IXUSR or S_IRGRP
or S_IXGRP or S_IROTH or S_IXOTH); or S_IXGRP or S_IROTH or S_IXOTH);

View File

@ -128,7 +128,7 @@ implementation
uses uses
paszlib,DCPbase64,math, client,tpa, paszlib,DCPbase64,math, client,tpa,
colour_conv,IOManager,mufasatypesutil; colour_conv,IOManager,mufasatypesutil,FileUtil;
// Needs more fixing. We need to either copy the memory ourself, or somehow // Needs more fixing. We need to either copy the memory ourself, or somehow
// find a TRawImage feature to skip X bytes after X bytes read. (Most likely a // find a TRawImage feature to skip X bytes after X bytes read. (Most likely a
@ -482,7 +482,7 @@ begin
// Bmp := Graphics.TBitmap.Create; // Bmp := Graphics.TBitmap.Create;
try try
Bmp := TLazIntfImage.Create(RawImage,false); Bmp := TLazIntfImage.Create(RawImage,false);
Bmp.SaveToFile(FileName); Bmp.SaveToFile(UTF8ToSys(FileName));
Bmp.Free; Bmp.Free;
except except
result := false; result := false;
@ -494,12 +494,12 @@ var
LazIntf : TLazIntfImage; LazIntf : TLazIntfImage;
RawImageDesc : TRawImageDescription; RawImageDesc : TRawImageDescription;
begin begin
if FileExists(FileName) then if FileExistsUTF8(FileName) then
begin; begin;
LazIntf := TLazIntfImage.Create(0,0); LazIntf := TLazIntfImage.Create(0,0);
RawImageDesc.Init_BPP32_B8G8R8_BIO_TTB(LazIntf.Width,LazIntf.Height); RawImageDesc.Init_BPP32_B8G8R8_BIO_TTB(LazIntf.Width,LazIntf.Height);
LazIntf.DataDescription := RawImageDesc; LazIntf.DataDescription := RawImageDesc;
LazIntf.LoadFromFile(FileName); LazIntf.LoadFromFile(UTF8ToSys(FileName));
if Assigned(FData) then if Assigned(FData) then
Freemem(FData); Freemem(FData);
Self.W := LazIntf.Width; Self.W := LazIntf.Width;

View File

@ -69,7 +69,7 @@ type
implementation implementation
uses uses
{$IFDEF MSWINDOWS}Windows,{$ENDIF} IniFiles,Client; {$IFDEF MSWINDOWS}Windows,{$ENDIF} IniFiles,Client,FileUtil;
{ GetFiles in independant of the TMFiles class } { GetFiles in independant of the TMFiles class }
@ -115,13 +115,13 @@ function FindFile(filename : string; Dirs : array of string) : string; //Results
var var
i : integer; i : integer;
begin; begin;
if fileexists(filename) then if FileExistsUTF8(filename) then
result := filename result := filename
else else
begin begin
for i := 0 to high(Dirs) do for i := 0 to high(Dirs) do
if (Dirs[i] <> '') and DirectoryExists(dirs[i]) then if (Dirs[i] <> '') and DirectoryExists(dirs[i]) then
if fileexists(dirs[i] + filename) then if fileexistsUTF8(dirs[i] + filename) then
begin begin
result := dirs[i] + filename; result := dirs[i] + filename;
exit; exit;
@ -232,7 +232,7 @@ begin
exit(File_EventError); exit(File_EventError);
end; end;
try try
FS := TFileStream.Create(Path, fmCreate); FS := TFileStream.Create(UTF8ToSys(Path), fmCreate);
Result := AddFileToManagedList(Path, FS, fmCreate); Result := AddFileToManagedList(Path, FS, fmCreate);
except except
Result := File_AccesError; Result := File_AccesError;
@ -264,7 +264,7 @@ begin
else else
fMode := fmOpenRead or fmShareExclusive; fMode := fmOpenRead or fmShareExclusive;
try try
FS := TFileStream.Create(Path, fMode) FS := TFileStream.Create(UTF8ToSys(Path), fMode)
except except
Result := File_AccesError; Result := File_AccesError;
TClient(Client).Writeln(Format('OpenFile - Exception. Could not open file: %s',[path])); TClient(Client).Writeln(Format('OpenFile - Exception. Could not open file: %s',[path]));
@ -297,7 +297,7 @@ begin
else else
fMode := fmOpenReadWrite or fmShareDenyWrite or fmShareDenyRead or fmCreate; fMode := fmOpenReadWrite or fmShareDenyWrite or fmShareDenyRead or fmCreate;
try try
FS := TFileStream.Create(Path, fMode); FS := TFileStream.Create(UTF8ToSys(Path), fMode);
FS.Size:=0; FS.Size:=0;
Result := AddFileToManagedList(Path, FS, fMode); Result := AddFileToManagedList(Path, FS, fMode);
except except

View File

@ -126,7 +126,7 @@ implementation
ValidateDirs; ValidateDirs;
PluginName := ExtractFileNameWithoutExt(PluginName); PluginName := ExtractFileNameWithoutExt(PluginName);
for i := 0 to PluginDirs.Count - 1 do for i := 0 to PluginDirs.Count - 1 do
if FileExists(PluginDirs.Strings[i] + Pluginname + PlugExt) then if FileExistsUTF8(PluginDirs.Strings[i] + Pluginname + PlugExt) then
begin; begin;
if ii <> -1 then if ii <> -1 then
Raise Exception.CreateFmt('Plugin(%s) has been found multiple times',[PluginName]); Raise Exception.CreateFmt('Plugin(%s) has been found multiple times',[PluginName]);