goo/gfile.cc | 10 +++++----- goo/gfile.h | 3 ++- poppler/GlobalParamsWin.cc | 2 +- poppler/PDFDoc.cc | 4 ++-- utils/pdfattach.cc | 6 +++--- 5 files changed, 13 insertions(+), 12 deletions(-)
New commits: commit 153df8e9b5262795db43d47642a7df77d8fbedcb Author: Albert Astals Cid <[email protected]> Date: Sun Nov 7 23:20:56 2021 +0100 Make GooFile::open take a std::string instead of a GooString diff --git a/goo/gfile.cc b/goo/gfile.cc index 277fd4d5..98fe7b7f 100644 --- a/goo/gfile.cc +++ b/goo/gfile.cc @@ -19,7 +19,7 @@ // Copyright (C) 2006 Kristian Høgsberg <[email protected]> // Copyright (C) 2008 Adam Batkin <[email protected]> // Copyright (C) 2008, 2010, 2012, 2013 Hib Eris <[email protected]> -// Copyright (C) 2009, 2012, 2014, 2017, 2018 Albert Astals Cid <[email protected]> +// Copyright (C) 2009, 2012, 2014, 2017, 2018, 2021 Albert Astals Cid <[email protected]> // Copyright (C) 2009 Kovid Goyal <[email protected]> // Copyright (C) 2013, 2018 Adam Reichold <[email protected]> // Copyright (C) 2013, 2017 Adrian Johnson <[email protected]> @@ -358,9 +358,9 @@ Goffset GooFile::size() const return size.QuadPart; } -GooFile *GooFile::open(const GooString *fileName) +GooFile *GooFile::open(const std::string &fileName) { - HANDLE handle = CreateFileA(fileName->c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); + HANDLE handle = CreateFileA(fileName.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); return handle == INVALID_HANDLE_VALUE ? nullptr : new GooFile(handle); } @@ -400,9 +400,9 @@ Goffset GooFile::size() const # endif } -GooFile *GooFile::open(const GooString *fileName) +GooFile *GooFile::open(const std::string &fileName) { - int fd = openFileDescriptor(fileName->c_str(), O_RDONLY); + int fd = openFileDescriptor(fileName.c_str(), O_RDONLY); return fd < 0 ? nullptr : new GooFile(fd); } diff --git a/goo/gfile.h b/goo/gfile.h index 637bcdc1..d04b9ac6 100644 --- a/goo/gfile.h +++ b/goo/gfile.h @@ -41,6 +41,7 @@ #include <cstdlib> #include <cstddef> #include <ctime> +#include <string> extern "C" { #if defined(_WIN32) # include <sys/stat.h> @@ -121,7 +122,7 @@ public: int read(char *buf, int n, Goffset offset) const; Goffset size() const; - static GooFile *open(const GooString *fileName); + static GooFile *open(const std::string &fileName); #ifdef _WIN32 static GooFile *open(const wchar_t *fileName); diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc index 0d44f736..13e98b25 100644 --- a/poppler/GlobalParamsWin.cc +++ b/poppler/GlobalParamsWin.cc @@ -414,7 +414,7 @@ void GlobalParams::setupBaseFonts(const char *dir) fileName->append("/cidfmap"); // try to open file - file = GooFile::open(fileName); + file = GooFile::open(fileName->toStr()); if (file != nullptr) { Parser *parser; diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index 53b44c59..86c97486 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -164,7 +164,7 @@ PDFDoc::PDFDoc(const GooString *fileNameA, const GooString *ownerPassword, const file = GooFile::open(wFileName); gfree(wFileName); #else - file = GooFile::open(fileName); + file = GooFile::open(fileName->toStr()); #endif if (file == nullptr) { // fopen() has failed. @@ -209,7 +209,7 @@ PDFDoc::PDFDoc(wchar_t *fileNameA, int fileNameLen, GooString *ownerPassword, Go if (version.dwPlatformId == VER_PLATFORM_WIN32_NT) { file = GooFile::open(fileNameU); } else { - file = GooFile::open(fileName); + file = GooFile::open(fileName->toStr()); } if (!file) { error(errIO, -1, "Couldn't open file '{0:t}'", fileName); diff --git a/utils/pdfattach.cc b/utils/pdfattach.cc index 192a0096..d5b6f1b2 100644 --- a/utils/pdfattach.cc +++ b/utils/pdfattach.cc @@ -4,7 +4,7 @@ // // This file is licensed under the GPLv2 or later // -// Copyright (C) 2019, 2020 Albert Astals Cid <[email protected]> +// Copyright (C) 2019-2021 Albert Astals Cid <[email protected]> // Copyright (C) 2019 Oliver Sander <[email protected]> // // To see a description of the changes please see the Changelog file that @@ -61,7 +61,7 @@ int main(int argc, char *argv[]) return 99; } const GooString pdfFileName(argv[1]); - const GooString attachFilePath(argv[2]); + const std::string attachFilePath(argv[2]); // init GlobalParams globalParams = std::make_unique<GlobalParams>(); @@ -74,7 +74,7 @@ int main(int argc, char *argv[]) return 1; } - std::unique_ptr<GooFile> attachFile(GooFile::open(&attachFilePath)); + std::unique_ptr<GooFile> attachFile(GooFile::open(attachFilePath)); if (!attachFile) { fprintf(stderr, "Couldn't open %s\n", attachFilePath.c_str()); return 2;
