diff --git a/sjasm/directives.cpp b/sjasm/directives.cpp index 6fe73a47..11ad2901 100644 --- a/sjasm/directives.cpp +++ b/sjasm/directives.cpp @@ -580,7 +580,7 @@ static void dirINCBIN() { length = val; } } - BinIncFile(fnaam.string().c_str(), offset, length, system_paths_first); //FIXME path idea ready with refactoring + BinIncFile(fnaam.c_str(), offset, length, system_paths_first); //FIXME path idea ready with refactoring } static void dirINCHOB() { @@ -613,12 +613,12 @@ static void dirINCHOB() { } } - fnaamh = GetPath(fnaam.string().c_str(), nullptr, system_paths_first); //FIXME path idea ready + fnaamh = GetPath(fnaam.c_str(), nullptr, system_paths_first); //FIXME path idea ready if (!FOPEN_ISOK(ff, fnaamh, "rb")) { - Error("[INCHOB] Error opening file", fnaam.string().c_str(), FATAL); + Error("[INCHOB] Error opening file", fnaam.c_str(), FATAL); } if (fseek(ff, 0x0b, 0) || 2 != fread(len, 1, 2, ff)) { - Error("[INCHOB] Hobeta file has wrong format", fnaam.string().c_str(), FATAL); + Error("[INCHOB] Hobeta file has wrong format", fnaam.c_str(), FATAL); } fclose(ff); if (length == -1) { @@ -626,7 +626,7 @@ static void dirINCHOB() { length = len[0] + (len[1] << 8) - offset; } offset += 17; // adjust offset (skip HOB header) - BinIncFile(fnaam.string().c_str(), offset, length, system_paths_first); //FIXME path idea ready w/ refactoring + BinIncFile(fnaam.c_str(), offset, length, system_paths_first); //FIXME path idea ready w/ refactoring free(fnaamh); } @@ -670,8 +670,8 @@ static void dirINCTRD() { length = val; } } - if (TRD_PrepareIncFile(trdname.string().c_str(), filename.c_str(), offset, length, system_paths_first)) { //FIXME path idea ready w/ refactoring^2 - BinIncFile(trdname.string().c_str(), offset, length, system_paths_first); //FIXME path idea ready w/ refactoring + if (TRD_PrepareIncFile(trdname.c_str(), filename.c_str(), offset, length, system_paths_first)) { //FIXME path idea ready w/ refactoring^2 + BinIncFile(trdname.c_str(), offset, length, system_paths_first); //FIXME path idea ready w/ refactoring } } @@ -1483,7 +1483,7 @@ static void dirINCLUDE() { if (fnaam.has_filename()) { EDelimiterType dt = GetDelimiterOfLastFileName(); ListFile(); - IncludeFile(fnaam.string().c_str(), DT_ANGLE == dt); //FIXME path idea possible with refactoring^2 + IncludeFile(fnaam.c_str(), DT_ANGLE == dt); //FIXME path idea possible with refactoring^2 donotlist = 1; } else { Error("[INCLUDE] empty filename", bp); @@ -1590,7 +1590,7 @@ static void dirEXPORT() { assert(!sourcePosStack.empty()); Options::ExportFName = sourcePosStack.back().filename; Options::ExportFName.replace_extension(".exp"); - Warning("[EXPORT] Filename for exportfile was not indicated. Output will be in", Options::ExportFName.string().c_str(), W_EARLY); + Warning("[EXPORT] Filename for exportfile was not indicated. Output will be in", Options::ExportFName.c_str(), W_EARLY); } if (!(n = p = GetID(lp))) { Error("[EXPORT] Syntax error", lp, SUPPRESS); diff --git a/sjasm/io_cpc.cpp b/sjasm/io_cpc.cpp index 8f08038f..5269c8a3 100644 --- a/sjasm/io_cpc.cpp +++ b/sjasm/io_cpc.cpp @@ -37,7 +37,7 @@ namespace { // report error and close the file static int writeError(const std::filesystem::path & fname, FILE*& fileToClose) { - Error("[SAVECPCSNA] Write error (disk full?)", fname.string().c_str(), IF_FIRST); + Error("[SAVECPCSNA] Write error (disk full?)", fname.c_str(), IF_FIRST); fclose(fileToClose); return 0; } @@ -62,7 +62,7 @@ static int SaveSNA_CPC(const std::filesystem::path & fname, word start) { FILE* ff; if (!FOPEN_ISOK(ff, fname, "wb")) { - Error("[SAVECPCSNA] Error opening file for write", fname.string().c_str()); + Error("[SAVECPCSNA] Error opening file for write", fname.c_str()); return 0; } @@ -785,7 +785,7 @@ void dirSAVECDT() { static int SaveCPR(const std::filesystem::path & fname, int cprSize) { FILE* ff; if (!FOPEN_ISOK(ff, fname, "wb")) { - Error("[SAVECPR] Error opening file for write", fname.string().c_str()); + Error("[SAVECPR] Error opening file for write", fname.c_str()); return 0; } diff --git a/sjasm/io_nex.cpp b/sjasm/io_nex.cpp index d6ec3144..eb79d464 100644 --- a/sjasm/io_nex.cpp +++ b/sjasm/io_nex.cpp @@ -299,7 +299,7 @@ void SBmpFile::close() { bool SBmpFile::open(const std::filesystem::path & bmpname) { if (!FOPEN_ISOK(bmp, bmpname, "rb")) { - Error("[SAVENEX] Error opening file", bmpname.string().c_str(), SUPPRESS); + Error("[SAVENEX] Error opening file", bmpname.c_str(), SUPPRESS); return false; } palBuffer = new byte[4*PALETTE_SIZE]; @@ -324,7 +324,7 @@ bool SBmpFile::open(const std::filesystem::path & bmpname) { 40 != header2Size || 1 != colorPlanes || 8 != bpp || 0 != compressionType) { Error("[SAVENEX] BMP file is not in expected format (uncompressed, 8bpp, 40B BITMAPINFOHEADER header)", - bmpname.string().c_str(), SUPPRESS); + bmpname.c_str(), SUPPRESS); close(); return false; } @@ -438,7 +438,7 @@ static void dirNexOpen() { return; } // try to open the actual file - if (!FOPEN_ISOK(nex.f, fname, "w+b")) Error("[SAVENEX] Error opening file for write", fname.string().c_str(), SUPPRESS); + if (!FOPEN_ISOK(nex.f, fname, "w+b")) Error("[SAVENEX] Error opening file for write", fname.c_str(), SUPPRESS); if (nullptr == nex.f) return; // set the argument values into header, and write the initial version of header into file nex.h.pc = openArgs[0] & 0xFFFF; @@ -753,7 +753,7 @@ static void dirNexScreenBmp() { SBmpFile bmp; bool bmpOpened = bmp.open(bmpname); if (bmpOpened && other == bmp.type) { - Error("[SAVENEX] BMP file is not 256x192, 128x96, 320x256 or 640x256", bmpname.string().c_str(), SUPPRESS); + Error("[SAVENEX] BMP file is not 256x192, 128x96, 320x256 or 640x256", bmpname.c_str(), SUPPRESS); bmpOpened = false; } if (!bmpOpened) return; @@ -1043,7 +1043,7 @@ static void dirNexClose() { if (appendName.has_filename()) { // some append file requested, try to copy its content at tail of NEX FILE* appendF = nullptr; if (!FOPEN_ISOK(appendF, appendName, "rb")) { - Error("[SAVENEX] Error opening append file", appendName.string().c_str(), SUPPRESS); + Error("[SAVENEX] Error opening append file", appendName.c_str(), SUPPRESS); } else { static constexpr int copyBufSize = 0x4000; byte* copyBuffer = new byte[copyBufSize]; diff --git a/sjasm/io_snapshots.cpp b/sjasm/io_snapshots.cpp index c279c1e7..5248e1e2 100644 --- a/sjasm/io_snapshots.cpp +++ b/sjasm/io_snapshots.cpp @@ -30,7 +30,7 @@ // report error and close the file static bool writeError(const std::filesystem::path & fname, FILE* & fileToClose) { - Error("Write error (disk full?)", fname.string().c_str(), IF_FIRST); + Error("Write error (disk full?)", fname.c_str(), IF_FIRST); fclose(fileToClose); return false; } @@ -47,7 +47,7 @@ bool SaveSNA_ZX(const std::filesystem::path & fname, word start) { FILE* ff; if (!FOPEN_ISOK(ff, fname, "wb")) { - Error("opening file for write", fname.string().c_str()); + Error("opening file for write", fname.c_str()); return false; } @@ -139,7 +139,7 @@ bool SaveSNA_ZX(const std::filesystem::path & fname, word start) { } if (128*1024 < Device->PagesCount * Device->GetPage(0)->Size) { - WarningById(W_SNA_128, fname.string().c_str()); + WarningById(W_SNA_128, fname.c_str()); } fclose(ff); diff --git a/sjasm/io_tape.cpp b/sjasm/io_tape.cpp index 54cc7327..ef09d1bc 100644 --- a/sjasm/io_tape.cpp +++ b/sjasm/io_tape.cpp @@ -45,7 +45,7 @@ static aint detect_ram_start(unsigned char* ram, aint length); int TAP_SaveEmpty(const std::filesystem::path & fname) { FILE* ff; if (!FOPEN_ISOK(ff, fname, "wb")) { - Error("opening file for write", fname.string().c_str()); return 0; + Error("opening file for write", fname.c_str()); return 0; } fclose(ff); return 1; @@ -54,7 +54,7 @@ int TAP_SaveEmpty(const std::filesystem::path & fname) { int TAP_SaveBlock(const std::filesystem::path & fname, unsigned char flag, const char *ftapname, int start, int length, int param2, int param3) { FILE* fpout; if (!FOPEN_ISOK(fpout, fname, "ab")) { - Error("opening file for append", fname.string().c_str(), FATAL); + Error("opening file for append", fname.c_str(), FATAL); } if (length + start > 0x10000) { @@ -136,7 +136,7 @@ int TAP_SaveBlock(const std::filesystem::path & fname, unsigned char flag, const int TAP_SaveSnapshot(const std::filesystem::path & fname, unsigned short start) { FILE* fpout; if (!FOPEN_ISOK(fpout, fname, "wb")) { - Error("opening file for write", fname.string().c_str(), FATAL); + Error("opening file for write", fname.c_str(), FATAL); } aint datastart = 0x5E00; diff --git a/sjasm/io_trd.cpp b/sjasm/io_trd.cpp index fdeb2b31..cad84e59 100644 --- a/sjasm/io_trd.cpp +++ b/sjasm/io_trd.cpp @@ -184,7 +184,7 @@ static int saveEmptyWrite(FILE* ff, byte* buf, const char label[8]) { bool TRD_SaveEmpty(const std::filesystem::path & fname, const char label[8]) { FILE* ff; if (!fname.has_filename() || !FOPEN_ISOK(ff, fname, "wb")) { - Error("opening file for write", fname.string().c_str(), IF_FIRST); + Error("opening file for write", fname.c_str(), IF_FIRST); return 0; } byte* buf = (byte*) calloc(STrdDisc::SECTORS_PER_TRACK*STrdDisc::SECTOR_SZ, sizeof(byte)); @@ -192,7 +192,7 @@ bool TRD_SaveEmpty(const std::filesystem::path & fname, const char label[8]) { int result = saveEmptyWrite(ff, buf, label); free(buf); fclose(ff); - if (!result) Error("Write error (disk full?)", fname.string().c_str(), IF_FIRST); + if (!result) Error("Write error (disk full?)", fname.c_str(), IF_FIRST); return result; } @@ -226,7 +226,7 @@ ETrdFileName TRD_FileNameToBytes(const char* inputName, byte binName[12], int & static int ReturnWithError(const char* errorText, const std::filesystem::path & fname, FILE* fileToClose) { if (nullptr != fileToClose) fclose(fileToClose); - Error(errorText, fname.string().c_str(), IF_FIRST); + Error(errorText, fname.c_str(), IF_FIRST); return 0; } @@ -366,7 +366,7 @@ bool TRD_AddFile(const std::filesystem::path & fname, const char* fhobname, int if (STrdHead::NUM_OF_FILES_MAX != fileIndex) { // to keep legacy behaviour of older sjasmplus versions, this is just warning // and the same file will be added to end of directory any way - WarningById(W_TRD_DUPLICATE, fname.string().c_str()); + WarningById(W_TRD_DUPLICATE, fname.c_str()); } fileIndex = trdHead.info.numOfFiles; } @@ -493,7 +493,7 @@ int TRD_PrepareIncFile(const std::filesystem::path & trdname, const char* filena // read 9 sectors of disk into "trdHead" (contains root directory catalog and disk info data) STrdHead trdHead; - char* fullTrdName = GetPath(trdname.string().c_str(), nullptr, systemPathsFirst); //FIXME path idea ready with refactoring^2 + char* fullTrdName = GetPath(trdname.c_str(), nullptr, systemPathsFirst); //FIXME path idea ready with refactoring^2 FILE* ff = SJ_fopen(fullTrdName, "rb"); free(fullTrdName); fullTrdName = nullptr; diff --git a/sjasm/io_tzx.cpp b/sjasm/io_tzx.cpp index e37b3176..7647e49d 100644 --- a/sjasm/io_tzx.cpp +++ b/sjasm/io_tzx.cpp @@ -35,7 +35,7 @@ namespace TZXBlockId { void TZX_CreateEmpty(const std::filesystem::path & fname) { FILE* ff; if (!FOPEN_ISOK(ff, fname, "wb")) { - Error("[TZX] Error opening file for write", fname.string().c_str(), FATAL); + Error("[TZX] Error opening file for write", fname.c_str(), FATAL); } constexpr byte tzx_major_version = 1; @@ -54,7 +54,7 @@ void TZX_AppendPauseBlock(const std::filesystem::path & fname, uint16_t pauseAft { FILE* ff; if (!FOPEN_ISOK(ff, fname, "a+b")) { - Error("[TZX] Error opening file for append", fname.string().c_str(), FATAL); + Error("[TZX] Error opening file for append", fname.c_str(), FATAL); } fputc(TZXBlockId::Pause, ff); // block id @@ -67,7 +67,7 @@ void TZX_AppendStandardBlock(const std::filesystem::path & fname, const byte* buf, const aint buflen, word pauseAfterMs, byte sync) { FILE* ff; if (!FOPEN_ISOK(ff, fname, "a+b")) { - Error("[TZX] Error opening file for append", fname.string().c_str(), FATAL); + Error("[TZX] Error opening file for append", fname.c_str(), FATAL); } const aint totalDataLen = buflen + 2; // + sync byte + checksum @@ -91,7 +91,7 @@ void TZX_AppendTurboBlock(const std::filesystem::path & fname, const byte* buf, const aint buflen, const STZXTurboBlock& turbo) { FILE* ff; if (!FOPEN_ISOK(ff, fname, "a+b")) { - Error("[TZX] Error opening file for append", fname.string().c_str(), FATAL); + Error("[TZX] Error opening file for append", fname.c_str(), FATAL); } fputc(TZXBlockId::Turbo, ff); // block id diff --git a/sjasm/sjio.cpp b/sjasm/sjio.cpp index 399f06a4..0d19af74 100644 --- a/sjasm/sjio.cpp +++ b/sjasm/sjio.cpp @@ -821,7 +821,7 @@ static void OpenListImp(const std::filesystem::path & listFilename) { if (OV_LST == Options::OutputVerbosity) return; if (listFilename.empty()) return; if (!FOPEN_ISOK(FP_ListingFile, listFilename, "w")) { - Error("opening file for write", listFilename.string().c_str(), FATAL); + Error("opening file for write", listFilename.c_str(), FATAL); } } @@ -891,7 +891,7 @@ void OpenDest(int mode) { mode = OUTPUT_TRUNCATE; } if (!Options::NoDestinationFile && !FOPEN_ISOK(FP_Output, Options::DestinationFName, mode == OUTPUT_TRUNCATE ? "wb" : "r+b")) { - Error("opening file for write", Options::DestinationFName.string().c_str(), FATAL); + Error("opening file for write", Options::DestinationFName.c_str(), FATAL); } Options::NoDestinationFile = false; if (NULL == FP_RAW && "-" == Options::RAWFName) { @@ -900,7 +900,7 @@ void OpenDest(int mode) { switchStdOutIntoBinaryMode(); } if (FP_RAW == NULL && Options::RAWFName.has_filename() && !FOPEN_ISOK(FP_RAW, Options::RAWFName, "wb")) { - Error("opening file for write", Options::RAWFName.string().c_str()); + Error("opening file for write", Options::RAWFName.c_str()); } if (FP_Output != NULL && mode != OUTPUT_TRUNCATE) { if (fseek(FP_Output, 0, mode == OUTPUT_REWIND ? SEEK_SET : SEEK_END)) { @@ -934,10 +934,10 @@ void OpenTapFile(const std::filesystem::path & tapename, int flagbyte) CloseTapFile(); if (!FOPEN_ISOK(FP_tapout,tapename, "r+b")) { - Error( "opening file for write", tapename.string().c_str()); + Error( "opening file for write", tapename.c_str()); return; } - if (fseek(FP_tapout, 0, SEEK_END)) Error("File seek end error in TAPOUT", tapename.string().c_str(), FATAL); + if (fseek(FP_tapout, 0, SEEK_END)) Error("File seek end error in TAPOUT", tapename.c_str(), FATAL); tape_seek = ftell(FP_tapout); tape_parity = flagbyte; @@ -1042,7 +1042,7 @@ unsigned char MemGetByte(unsigned int address) { int SaveBinary(const std::filesystem::path & fname, aint start, aint length) { FILE* ff; - if (!FOPEN_ISOK(ff, fname, "wb")) Error("opening file for write", fname.string().c_str(), FATAL); + if (!FOPEN_ISOK(ff, fname, "wb")) Error("opening file for write", fname.c_str(), FATAL); int result = SaveRAM(ff, start, length); fclose(ff); return result; @@ -1051,7 +1051,7 @@ int SaveBinary(const std::filesystem::path & fname, aint start, aint length) { int SaveBinary3dos(const std::filesystem::path & fname, aint start, aint length, byte type, word w2, word w3) { FILE* ff; - if (!FOPEN_ISOK(ff, fname, "wb")) Error("opening file for write", fname.string().c_str(), FATAL); + if (!FOPEN_ISOK(ff, fname, "wb")) Error("opening file for write", fname.c_str(), FATAL); // prepare +3DOS 128 byte header content constexpr aint hsize = 128; const aint full_length = hsize + length; @@ -1081,7 +1081,7 @@ int SaveBinary3dos(const std::filesystem::path & fname, aint start, aint length, int SaveBinaryAmsdos(const std::filesystem::path & fname, aint start, aint length, word start_adr, byte type) { FILE* ff; if (!FOPEN_ISOK(ff, fname, "wb")) { - Error("opening file for write", fname.string().c_str(), SUPPRESS); + Error("opening file for write", fname.c_str(), SUPPRESS); return 0; } // prepare AMSDOS 128 byte header content @@ -1115,7 +1115,7 @@ bool SaveDeviceMemory(FILE* file, const size_t start, const size_t length) { // start and length must be sanitized by caller bool SaveDeviceMemory(const std::filesystem::path & fname, const size_t start, const size_t length) { FILE* ff; - if (!FOPEN_ISOK(ff, fname, "wb")) Error("opening file for write", fname.string().c_str(), FATAL); + if (!FOPEN_ISOK(ff, fname, "wb")) Error("opening file for write", fname.c_str(), FATAL); bool res = SaveDeviceMemory(ff, start, length); fclose(ff); return res; @@ -1172,7 +1172,7 @@ int SaveHobeta(const std::filesystem::path & fname, const char* fhobname, aint s FILE* ff; if (!FOPEN_ISOK(ff, fname, "wb")) { - Error("opening file for write", fname.string().c_str(), FATAL); + Error("opening file for write", fname.c_str(), FATAL); } int result = (17 == fwrite(header, 1, 17, ff)) && SaveRAM(ff, start, length); @@ -1305,7 +1305,7 @@ void OpenExpFile() { assert(nullptr == FP_ExportFile); // this should be the first and only call to open it if (!Options::ExportFName.has_filename()) return; // no export file name provided, skip opening if (FOPEN_ISOK(FP_ExportFile, Options::ExportFName, "w")) return; - Error("opening file for write", Options::ExportFName.string().c_str(), ALL); + Error("opening file for write", Options::ExportFName.c_str(), ALL); } void WriteLabelEquValue(const char* name, aint value, FILE* f) { @@ -1342,7 +1342,7 @@ static void WriteToSldFile_TextFilePos(char* buffer, const TextFilePos & pos) { static void OpenSldImp(const std::filesystem::path & sldFilename) { if (!sldFilename.has_filename()) return; if (!FOPEN_ISOK(FP_SourceLevelDebugging, sldFilename, "w")) { - Error("opening file for write", sldFilename.string().c_str(), FATAL); + Error("opening file for write", sldFilename.c_str(), FATAL); } fputs("|SLD.data.version|1\n", FP_SourceLevelDebugging); if (0 < sldCommentKeywords.size()) { @@ -1476,7 +1476,7 @@ static int breakpointsCounter; void OpenBreakpointsFile(const std::filesystem::path & filename, const EBreakpointsFile type) { if (!filename.has_filename()) { - Error("empty filename", filename.string().c_str(), EARLY); + Error("empty filename", filename.c_str(), EARLY); return; } if (FP_BreakpointsFile) { @@ -1484,7 +1484,7 @@ void OpenBreakpointsFile(const std::filesystem::path & filename, const EBreakpoi return; } if (!FOPEN_ISOK(FP_BreakpointsFile, filename, "w")) { - Error("opening file for write", filename.string().c_str(), EARLY); + Error("opening file for write", filename.c_str(), EARLY); } breakpointsCounter = 0; breakpointsType = type; diff --git a/sjasm/support.cpp b/sjasm/support.cpp index 8b40e6b9..eee6eb1e 100644 --- a/sjasm/support.cpp +++ b/sjasm/support.cpp @@ -31,8 +31,8 @@ #include "sjdefs.h" FILE* SJ_fopen(const std::filesystem::path & fname, const char* mode) { - if (nullptr == mode || fname.empty()) return nullptr; - return fopen(fname.string().c_str(), mode); + if (nullptr == mode || fname.empty() || !fname.has_filename()) return nullptr; + return fopen(fname.c_str(), mode); } FILE* SJ_fopen(const char* fname, const char* mode) { diff --git a/sjasm/tables.cpp b/sjasm/tables.cpp index df81c1a5..4908ae3b 100644 --- a/sjasm/tables.cpp +++ b/sjasm/tables.cpp @@ -455,7 +455,7 @@ void CLabelTable::DumpForUnreal() { char ln[LINEMAX], * ep; FILE* FP_UnrealList; if (!FOPEN_ISOK(FP_UnrealList, Options::UnrealLabelListFName, "w")) { - Error("opening file for write", Options::UnrealLabelListFName.string().c_str(), FATAL); + Error("opening file for write", Options::UnrealLabelListFName.c_str(), FATAL); } const int PAGE_MASK = DeviceID ? Device->GetPage(0)->Size - 1 : 0x3FFF; const int ADR_MASK = Options::EmitVirtualLabels ? 0xFFFF : PAGE_MASK; @@ -489,7 +489,7 @@ void CLabelTable::DumpForUnreal() { void CLabelTable::DumpForCSpect() { FILE* file; if (!FOPEN_ISOK(file, Options::CSpectMapFName, "w")) { - Error("opening file for write", Options::CSpectMapFName.string().c_str(), FATAL); + Error("opening file for write", Options::CSpectMapFName.c_str(), FATAL); } const int CSD_PAGE_SIZE = Options::CSpectMapPageSize; const int CSD_PAGE_MASK = CSD_PAGE_SIZE - 1; @@ -541,7 +541,7 @@ void CLabelTable::DumpForCSpect() { void CLabelTable::DumpSymbols() { FILE* symfp; if (!FOPEN_ISOK(symfp, Options::SymbolListFName, "w")) { - Error("opening file for write", Options::SymbolListFName.string().c_str(), FATAL); + Error("opening file for write", Options::SymbolListFName.c_str(), FATAL); } const auto order = getDumpOrder(symbols); for (const symbol_map_t::key_type& name: order) {