var
OutputLocationOfFile : string;
try
OutputStreamNative := TFileStreamUTF8.Create(IncludeTrailingPathDelimiter(OutputSubFolderNATIVE) + UniqueID+'-'+ UTF16toUTF8(NativeFileName), fmCreate);
OutputLocationOfFile := IncludeTrailingPathDelimiter(OutputSubFolderNATIVE) + UniqueID+'-'+ UTF16toUTF8(NativeFileName); // All this to store the filename
except
on E: EFOpenError do
begin
errormessage := 'Could not write native filestream. Maybe permissions or disk storage issue? ' + E.Message;
lstrcpyw(Buf, errorMessage);
XWF_OutputMessage(@Buf[0], 0);
end;
end;
OutputLocationForNATIVE := '.\NATIVE\' + UniqueID+'-'+NativeFileName;
end
else
if FileNameLegal = false then
begin
try
OutputStreamNative := TFileStreamUTF8.Create(IncludeTrailingPathDelimiter(OutputSubFolderNATIVE) + UniqueID+'-'+UTF16toUTF8(CorrectedFilename), fmCreate);
OutputLocationOfFile := IncludeTrailingPathDelimiter(OutputSubFolderNATIVE) + UniqueID+'-'+UTF16toUTF8(CorrectedFilename); // All this to store the filename
except
on E: EFOpenError do
begin
errormessage := 'ERROR : Could not write native filestream as sanitised stream. Maybe a filename issue remaining? ' + E.Message;
lstrcpyw(Buf, errorMessage);
XWF_OutputMessage(@Buf[0], 0);
end;
end;
OutputLocationForNATIVE := '.\NATIVE\' + UniqueID+'-'+CorrectedFilename;
end
else
if TruncatedFileFlag = true then
begin
try
OutputStreamNative := TFileStreamUTF8.Create(IncludeTrailingPathDelimiter(OutputSubFolderNATIVE) + UniqueID+'-'+UTF16toUTF8(TruncatedFileName), fmCreate);
OutputLocationOfFile := IncludeTrailingPathDelimiter(OutputSubFolderNATIVE) + UniqueID+'-'+UTF16toUTF8(TruncatedFileName); // All this to store the filename
except
on E: EFOpenError do
begin
errormessage := 'ERROR : Could not create truncated filestream. Maybe filename has not been suitbly shortened? Check length? ' + E.Message;
lstrcpyw(Buf, errorMessage);
XWF_OutputMessage(@Buf[0], 0);
end;
end;
OutputLocationForNATIVE := '.\NATIVE\' + UniqueID+'-'+UTF16toUTF8(TruncatedFilename);
end;
WriteSuccess := -1;
WriteSuccess := OutputStreamNative.Write(InputBytesBuffer[0], ItemSize);
if WriteSuccess = -1 then
begin
errormessage := 'ERROR : ' + UniqueID+'-'+NativeFileName + ' could not be written to disk. FileStream write error.';
lstrcpyw(Buf, errormessage);
XWF_OutputMessage(@Buf[0], 0);
end;
finally
OutputStreamNative.free;
end;