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:
parent
62bfea8be2
commit
4f6ad407e1
@ -46,7 +46,7 @@ uses
|
||||
CastaliaSimplePasPar, v_AutoCompleteForm, PSDump;
|
||||
|
||||
const
|
||||
SimbaVersion = 668;
|
||||
SimbaVersion = 670;
|
||||
|
||||
type
|
||||
|
||||
@ -1426,10 +1426,8 @@ begin
|
||||
if (Paramcount = 1) and not (Application.HasOption('open')) then
|
||||
begin
|
||||
writeln('Opening file: ' + ParamStr(1));
|
||||
if FileExists(ParamStr(1)) then
|
||||
begin
|
||||
LoadScriptFile(paramstr(1));
|
||||
end;
|
||||
if FileExistsUTF8(ParamStrUTF8(1)) then
|
||||
LoadScriptFile(ParamStrUTF8(1));
|
||||
end else
|
||||
// we have more parameters. Check for specific options. (-r -o, --run --open)
|
||||
begin
|
||||
@ -2819,7 +2817,7 @@ begin
|
||||
Filter:= 'Simba Files|*.Simba;*.simb;*.cogat;*.mufa;*.txt;*.' +LoadSettingDef('Settings/Extensions/FileExtension','sex')+
|
||||
'|Any files|*.*';
|
||||
if Execute then
|
||||
if FileExists(filename) then
|
||||
if FileExistsUTF8(filename) then
|
||||
result := LoadScriptFile(filename);
|
||||
finally
|
||||
Free;
|
||||
@ -2841,7 +2839,7 @@ begin
|
||||
CheckTabsFirst := True
|
||||
else
|
||||
CheckTabsFirst := (Lowercase(LoadSettingDef('Settings/Tabs/CheckTabsBeforeOpen','True')) = 'true');
|
||||
if FileExists(FileName) then
|
||||
if FileExistsUTF8(FileName) then
|
||||
begin;
|
||||
if CheckTabsFirst then
|
||||
begin;
|
||||
@ -2857,7 +2855,7 @@ begin
|
||||
with CurrScript do
|
||||
begin
|
||||
filename := SetDirSeparators(filename);
|
||||
SynEdit.Lines.LoadFromFile(FileName);
|
||||
SynEdit.Lines.LoadFromFile(filename);
|
||||
StartText := SynEdit.Lines.text;
|
||||
ScriptName:= ExtractFileNameOnly(filename);
|
||||
mDebugLn('Script name will be: ' + ScriptName);
|
||||
|
@ -70,20 +70,20 @@ begin
|
||||
end;
|
||||
function ps_FileExists ( const FileName : string ) : Boolean;extdecl;
|
||||
begin
|
||||
result := FileExists(FileName);
|
||||
result := FileExistsUTF8(FileName);
|
||||
end;
|
||||
function ps_DirectoryExists ( const DirectoryName : string ) : Boolean; extdecl;
|
||||
begin
|
||||
result := DirectoryExists(DirectoryName);
|
||||
result := DirectoryExistsUTF8(DirectoryName);
|
||||
end;
|
||||
function ps_CreateDirectory( const DirectoryName : string) : boolean; extdecl;
|
||||
begin
|
||||
result := CreateDir(directoryName);
|
||||
result := CreateDirUTF8(directoryName);
|
||||
end;
|
||||
|
||||
function ps_ForceDirectores(const dir : string) : boolean; extdecl;
|
||||
begin
|
||||
result := ForceDirectories(dir);
|
||||
result := ForceDirectoriesUTF8(dir);
|
||||
end;
|
||||
|
||||
function ps_GetFiles(const Path, Ext : string) : TStringArray;extdecl;
|
||||
@ -100,7 +100,7 @@ procedure ps_WriteINI(const Section, KeyName, NewString, FileName: string);extde
|
||||
var
|
||||
tempini : TIniFile;
|
||||
begin;
|
||||
tempini := TIniFile.Create(FileName,True);
|
||||
tempini := TIniFile.Create(UTF8ToSys(FileName),True);
|
||||
tempini.WriteString(Section,keyname,newstring);
|
||||
tempini.free;
|
||||
end;
|
||||
@ -109,7 +109,7 @@ function ps_ReadINI(const Section, KeyName, FileName: string): string;extdecl;
|
||||
var
|
||||
tempini : TIniFile;
|
||||
begin;
|
||||
tempini := TIniFile.Create(FileName,True);
|
||||
tempini := TIniFile.Create(UTF8ToSys(FileName),True);
|
||||
Result := tempini.ReadString(section,keyname,'');
|
||||
tempini.free;
|
||||
end;
|
||||
@ -118,7 +118,7 @@ procedure ps_DeleteINI(const Section, KeyName, FileName: string); extdecl;
|
||||
var
|
||||
tempini : TIniFile;
|
||||
begin;
|
||||
tempini := TIniFile.Create(FileName,True);
|
||||
tempini := TIniFile.Create(utf8tosys(FileName),True);
|
||||
if KeyName = '' then
|
||||
tempini.EraseSection(Section)
|
||||
else
|
||||
|
@ -53,6 +53,9 @@ type
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
FileUtil;
|
||||
|
||||
function DecompressBZip2(const input: TStream; const BlockSize: Cardinal): TMemoryStream;
|
||||
var
|
||||
Unzipper : TDecompressBzip2Stream;
|
||||
@ -128,10 +131,10 @@ begin;
|
||||
end;
|
||||
end else if (DirRec.FileType = ftNormal) then
|
||||
begin;
|
||||
if FileExists(outputdir + dirrec.name) and not overwrite then
|
||||
if FileExistsUTF8(outputdir + dirrec.name) and not overwrite then
|
||||
continue;
|
||||
try
|
||||
FS := TFileStream.Create(outputdir +dirrec.name,fmCreate);
|
||||
FS := TFileStream.Create(UTF8ToSys(outputdir +dirrec.name),fmCreate);
|
||||
tar.ReadFile(fs);
|
||||
FS.Free;
|
||||
except
|
||||
|
@ -220,6 +220,7 @@ uses
|
||||
math, //Maths!
|
||||
mmath, //Real maths!
|
||||
strutils,
|
||||
fileutil,
|
||||
tpa, //Tpa stuff
|
||||
forms,//Forms
|
||||
SynRegExpr,
|
||||
@ -406,7 +407,7 @@ begin
|
||||
Includes.Add(path);
|
||||
|
||||
try
|
||||
f:= TFileStream.Create(Path, fmOpenRead or fmShareDenyWrite);
|
||||
f:= TFileStream.Create(UTF8ToSys(Path), fmOpenRead or fmShareDenyWrite);
|
||||
SetLength(contents, f.Size);
|
||||
f.Read(contents[1], Length(contents));
|
||||
result:= true;
|
||||
|
@ -95,7 +95,7 @@ type
|
||||
|
||||
implementation
|
||||
uses
|
||||
stringutil;
|
||||
stringutil,fileutil;
|
||||
|
||||
constructor TSettingData.Create;
|
||||
begin
|
||||
@ -595,13 +595,13 @@ var
|
||||
Doc: TXMLDocument;
|
||||
begin
|
||||
Nodes.Clear;
|
||||
if not fileExists(fileName) then
|
||||
if not fileExistsUTF8(fileName) then
|
||||
begin
|
||||
mDebugLn('SettingsFile hasn''t been created yet.');
|
||||
// create file.
|
||||
SaveToXML(fileName);
|
||||
end;
|
||||
ReadXMLFile(Doc, fileName);
|
||||
ReadXMLFile(Doc, utf8tosys(fileName));
|
||||
InternalLoadFromXML(Doc);
|
||||
Doc.Free;
|
||||
end;
|
||||
@ -667,7 +667,7 @@ begin
|
||||
end;
|
||||
|
||||
try
|
||||
WriteXMLFile(XMLDoc, fileName);
|
||||
WriteXMLFile(XMLDoc, utf8tosys(fileName));
|
||||
except
|
||||
mDebugLn('Failed to write ' + fileName);
|
||||
end;
|
||||
|
@ -86,6 +86,9 @@ type
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
FileUtil;
|
||||
|
||||
|
||||
procedure TMMLFileDownloader.SetBasePath(s: string);
|
||||
begin
|
||||
@ -164,7 +167,7 @@ begin
|
||||
if FileURL = '' then
|
||||
raise Exception.Create('FileURL not set');
|
||||
|
||||
Response := TFileStream.Create(FBasePath + FReplacementFile + '_', fmCreate);
|
||||
Response := TFileStream.Create(UTF8ToSys(FBasePath + FReplacementFile + '_'), fmCreate);
|
||||
try
|
||||
Result := HTTPSend.HTTPMethod('GET', FileURL);
|
||||
|
||||
@ -199,21 +202,21 @@ begin
|
||||
exit(False);
|
||||
//raise Exception.Create('ReplacementFile not set');
|
||||
end;
|
||||
if not FileExists(FBasePath + FReplacementFile) then
|
||||
if not fileExistsUTF8(FBasePath + FReplacementFile) then
|
||||
begin
|
||||
mDebugLn('ReplacementFile not found');
|
||||
exit(False);
|
||||
//raise Exception.Create('ReplacementFile not found');
|
||||
end;
|
||||
if not FileExists(FBasePath + FReplacementFile+ '_') then
|
||||
if not fileExistsUTF8(FBasePath + FReplacementFile+ '_') then
|
||||
begin
|
||||
mDebugLn('ReplacementFile + _ not found');
|
||||
exit(False);
|
||||
//raise Exception.Create('ReplacementFile + _ not found');
|
||||
end;
|
||||
RenameFile(FBasePath + FReplacementFile, FBasePath + FReplacementFile+'_old_');
|
||||
RenameFile(FBasePath + FReplacementFile +'_', FBasePath + FReplacementFile);
|
||||
DeleteFile(FBasePath + FReplacementFile+'_old_');
|
||||
RenameFileUTF8(FBasePath + FReplacementFile, FBasePath + FReplacementFile+'_old_');
|
||||
RenameFileUTF8(FBasePath + FReplacementFile +'_', FBasePath + FReplacementFile);
|
||||
DeleteFileUTF8(FBasePath + FReplacementFile+'_old_');
|
||||
{$IFDEF LINUX}
|
||||
fpchmod(FBasePath + FReplacementFile, S_IRUSR or S_IWUSR or S_IXUSR or S_IRGRP
|
||||
or S_IXGRP or S_IROTH or S_IXOTH);
|
||||
|
@ -128,7 +128,7 @@ implementation
|
||||
|
||||
uses
|
||||
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
|
||||
// find a TRawImage feature to skip X bytes after X bytes read. (Most likely a
|
||||
@ -482,7 +482,7 @@ begin
|
||||
// Bmp := Graphics.TBitmap.Create;
|
||||
try
|
||||
Bmp := TLazIntfImage.Create(RawImage,false);
|
||||
Bmp.SaveToFile(FileName);
|
||||
Bmp.SaveToFile(UTF8ToSys(FileName));
|
||||
Bmp.Free;
|
||||
except
|
||||
result := false;
|
||||
@ -494,12 +494,12 @@ var
|
||||
LazIntf : TLazIntfImage;
|
||||
RawImageDesc : TRawImageDescription;
|
||||
begin
|
||||
if FileExists(FileName) then
|
||||
if FileExistsUTF8(FileName) then
|
||||
begin;
|
||||
LazIntf := TLazIntfImage.Create(0,0);
|
||||
RawImageDesc.Init_BPP32_B8G8R8_BIO_TTB(LazIntf.Width,LazIntf.Height);
|
||||
LazIntf.DataDescription := RawImageDesc;
|
||||
LazIntf.LoadFromFile(FileName);
|
||||
LazIntf.LoadFromFile(UTF8ToSys(FileName));
|
||||
if Assigned(FData) then
|
||||
Freemem(FData);
|
||||
Self.W := LazIntf.Width;
|
||||
|
@ -69,7 +69,7 @@ type
|
||||
|
||||
implementation
|
||||
uses
|
||||
{$IFDEF MSWINDOWS}Windows,{$ENDIF} IniFiles,Client;
|
||||
{$IFDEF MSWINDOWS}Windows,{$ENDIF} IniFiles,Client,FileUtil;
|
||||
|
||||
{ GetFiles in independant of the TMFiles class }
|
||||
|
||||
@ -115,13 +115,13 @@ function FindFile(filename : string; Dirs : array of string) : string; //Results
|
||||
var
|
||||
i : integer;
|
||||
begin;
|
||||
if fileexists(filename) then
|
||||
if FileExistsUTF8(filename) then
|
||||
result := filename
|
||||
else
|
||||
begin
|
||||
for i := 0 to high(Dirs) do
|
||||
if (Dirs[i] <> '') and DirectoryExists(dirs[i]) then
|
||||
if fileexists(dirs[i] + filename) then
|
||||
if fileexistsUTF8(dirs[i] + filename) then
|
||||
begin
|
||||
result := dirs[i] + filename;
|
||||
exit;
|
||||
@ -232,7 +232,7 @@ begin
|
||||
exit(File_EventError);
|
||||
end;
|
||||
try
|
||||
FS := TFileStream.Create(Path, fmCreate);
|
||||
FS := TFileStream.Create(UTF8ToSys(Path), fmCreate);
|
||||
Result := AddFileToManagedList(Path, FS, fmCreate);
|
||||
except
|
||||
Result := File_AccesError;
|
||||
@ -264,7 +264,7 @@ begin
|
||||
else
|
||||
fMode := fmOpenRead or fmShareExclusive;
|
||||
try
|
||||
FS := TFileStream.Create(Path, fMode)
|
||||
FS := TFileStream.Create(UTF8ToSys(Path), fMode)
|
||||
except
|
||||
Result := File_AccesError;
|
||||
TClient(Client).Writeln(Format('OpenFile - Exception. Could not open file: %s',[path]));
|
||||
@ -297,7 +297,7 @@ begin
|
||||
else
|
||||
fMode := fmOpenReadWrite or fmShareDenyWrite or fmShareDenyRead or fmCreate;
|
||||
try
|
||||
FS := TFileStream.Create(Path, fMode);
|
||||
FS := TFileStream.Create(UTF8ToSys(Path), fMode);
|
||||
FS.Size:=0;
|
||||
Result := AddFileToManagedList(Path, FS, fMode);
|
||||
except
|
||||
|
@ -126,7 +126,7 @@ implementation
|
||||
ValidateDirs;
|
||||
PluginName := ExtractFileNameWithoutExt(PluginName);
|
||||
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;
|
||||
if ii <> -1 then
|
||||
Raise Exception.CreateFmt('Plugin(%s) has been found multiple times',[PluginName]);
|
||||
|
Loading…
Reference in New Issue
Block a user