From 979f9089199512d32dcc2de1f1e00a96aa9b0bf4 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 5 May 2017 16:54:32 +0300 Subject: Rename virtfsrwops into rwops. --- src/CMakeLists.txt | 8 +- src/Makefile.am | 4 +- src/fs/virtfs/rwops.cpp | 146 ++++++++++++++++++++++++++++++++++ src/fs/virtfs/rwops.h | 66 +++++++++++++++ src/fs/virtfs/virtfs1_unittest.cc | 2 +- src/fs/virtfs/virtfsrwops.cpp | 146 ---------------------------------- src/fs/virtfs/virtfsrwops.h | 66 --------------- src/integrity_unittest.cc | 2 +- src/resources/atlas/atlasmanager.cpp | 2 +- src/resources/loaders/imageloader.cpp | 2 +- src/resources/loaders/musicloader.cpp | 2 +- src/resources/loaders/soundloader.cpp | 2 +- src/test/testlauncher.cpp | 2 +- 13 files changed, 225 insertions(+), 225 deletions(-) create mode 100644 src/fs/virtfs/rwops.cpp create mode 100644 src/fs/virtfs/rwops.h delete mode 100644 src/fs/virtfs/virtfsrwops.cpp delete mode 100644 src/fs/virtfs/virtfsrwops.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c62b11eba..71ca2aa29 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -891,8 +891,8 @@ SET(SRCS utils/perfomance.cpp utils/perfomance.h fs/virtfs/fsfuncs.h - fs/virtfs/virtfsrwops.cpp - fs/virtfs/virtfsrwops.h + fs/virtfs/rwops.cpp + fs/virtfs/rwops.h fs/virtfs/tools.cpp fs/virtfs/tools.h fs/virtfs/virtlist.cpp @@ -1800,8 +1800,8 @@ SET(DYE_CMD_SRCS utils/perfomance.cpp utils/perfomance.h fs/virtfs/fsfuncs.h - fs/virtfs/virtfsrwops.cpp - fs/virtfs/virtfsrwops.h + fs/virtfs/rwops.cpp + fs/virtfs/rwops.h fs/virtfs/tools.cpp fs/virtfs/tools.h fs/virtfs/virtlist.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 9684fab6b..b4c8e3e21 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -579,8 +579,8 @@ BASE_SRC += events/actionevent.h \ utils/perfomance.cpp \ utils/perfomance.h \ fs/virtfs/fsfuncs.h \ - fs/virtfs/virtfsrwops.cpp \ - fs/virtfs/virtfsrwops.h \ + fs/virtfs/rwops.cpp \ + fs/virtfs/rwops.h \ fs/virtfs/tools.cpp \ fs/virtfs/tools.h \ fs/virtfs/virtlist.cpp \ diff --git a/src/fs/virtfs/rwops.cpp b/src/fs/virtfs/rwops.cpp new file mode 100644 index 000000000..854c5510d --- /dev/null +++ b/src/fs/virtfs/rwops.cpp @@ -0,0 +1,146 @@ +/* + * The ManaPlus Client + * Copyright (C) 2013-2017 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* + * This code provides a glue layer between PhysicsFS and Simple Directmedia + * Layer's (SDL) RWops i/o abstraction. + * + * License: this code is public domain. I make no warranty that it is useful, + * correct, harmless, or environmentally safe. + * + * This particular file may be used however you like, including copying it + * verbatim into a closed-source project, exploiting it commercially, and + * removing any trace of my name from the source (although I hope you won't + * do that). I welcome enhancements and corrections to this file, but I do + * not require you to send me patches if you make changes. This code has + * NO WARRANTY. + * + * Unless otherwise stated, the rest of PhysicsFS falls under the zlib license. + * Please see LICENSE.txt in the root of the source tree. + * + * SDL falls under the LGPL license. You can get SDL at http://www.libsdl.org/ + * + * This file was written by Ryan C. Gordon. (icculus@icculus.org). + * + * Copyright (C) 2012-2017 The ManaPlus Developers + */ + +#include "fs/virtfs/rwops.h" + +#include "logger.h" + +#include "fs/virtfs/file.h" +#include "fs/virtfs/virtfs.h" +#include "fs/virtfs/fsfuncs.h" + +#include "utils/fuzzer.h" + +#include + +#include "debug.h" + +namespace VirtFs +{ + +SDL_RWops *create_rwops(File *const file) +{ + SDL_RWops *retval = nullptr; + + if (!file) + { + logger->assertLog("VirtFs::rwops_seek: create rwops error."); + } + else + { + retval = SDL_AllocRW(); + if (retval) + { +#ifdef USE_SDL2 + retval->size = file->funcs->rwops_size; +#endif // USE_SDL2 + + retval->seek = file->funcs->rwops_seek; + retval->read = file->funcs->rwops_read; + retval->write = file->funcs->rwops_write; + retval->close = file->funcs->rwops_close; + retval->hidden.unknown.data1 = file; + } /* if */ + } /* else */ + + return retval; +} /* VirtFs::create_rwops */ + +#ifdef __APPLE__ +static bool checkFilePath(const std::string &restrict fname) +{ + if (fname.empty()) + return false; + if (!exists(fname) || isDirectory(fname)) + return false; + return true; +} +#endif // __APPLE__ + +SDL_RWops *rwopsOpenRead(const std::string &restrict fname) +{ + BLOCK_START("RWopsopenRead") +#ifdef __APPLE__ + if (!checkFilePath(fname)) + return nullptr; +#endif // __APPLE__ +#ifdef USE_FUZZER + if (Fuzzer::conditionTerminate(fname)) + return nullptr; +#endif // USE_FUZZER +#ifdef USE_PROFILER + + SDL_RWops *const ret = create_rwops(openRead(fname)); + + BLOCK_END("RWopsopenRead") + return ret; +#else // USE_PROFILER + + return create_rwops(openRead(fname)); +#endif // USE_PROFILER +} /* RWopsopenRead */ + +SDL_RWops *rwopsOpenWrite(const std::string &restrict fname) +{ +#ifdef __APPLE__ + if (!checkFilePath(fname)) + return nullptr; +#endif // __APPLE__ + + return create_rwops(openWrite(fname)); +} /* RWopsopenWrite */ + +SDL_RWops *rwopsOpenAppend(const std::string &restrict fname) +{ +#ifdef __APPLE__ + if (!checkFilePath(fname)) + return nullptr; +#endif // __APPLE__ + + return create_rwops(openAppend(fname)); +} /* RWopsopenAppend */ + +} // namespace VirtFs + +/* end of virtfsrwops.c ... */ diff --git a/src/fs/virtfs/rwops.h b/src/fs/virtfs/rwops.h new file mode 100644 index 000000000..7be265ad2 --- /dev/null +++ b/src/fs/virtfs/rwops.h @@ -0,0 +1,66 @@ +/* + * The ManaPlus Client + * Copyright (C) 2013-2017 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* + * This code provides a glue layer between PhysicsFS and Simple Directmedia + * Layer's (SDL) RWops i/o abstraction. + * + * License: this code is public domain. I make no warranty that it is useful, + * correct, harmless, or environmentally safe. + * + * This particular file may be used however you like, including copying it + * verbatim into a closed-source project, exploiting it commercially, and + * removing any trace of my name from the source (although I hope you won't + * do that). I welcome enhancements and corrections to this file, but I do + * not require you to send me patches if you make changes. This code has + * NO WARRANTY. + * + * Unless otherwise stated, the rest of PhysicsFS falls under the zlib license. + * Please see LICENSE.txt in the root of the source tree. + * + * SDL falls under the LGPL license. You can get SDL at http://www.libsdl.org/ + * + * This file was written by Ryan C. Gordon. (icculus@icculus.org). + * + * Copyright (C) 2012-2017 The ManaPlus Developers + */ + +#ifndef SRC_FS_VIRTFSRWOPS_H +#define SRC_FS_VIRTFSRWOPS_H + +#include "localconsts.h" + +#include + +struct SDL_RWops; + +namespace VirtFs +{ + struct File; + + SDL_RWops *create_rwops(File *const file); + + SDL_RWops *rwopsOpenRead(const std::string &restrict fname); + SDL_RWops *rwopsOpenWrite(const std::string &restrict fname) A_WARN_UNUSED; + SDL_RWops *rwopsOpenAppend(const std::string &restrict fname) + A_WARN_UNUSED; +} // namespace VirtFs + +#endif // SRC_FS_VIRTFSRWOPS_H diff --git a/src/fs/virtfs/virtfs1_unittest.cc b/src/fs/virtfs/virtfs1_unittest.cc index dc8a610eb..b4bdcbb09 100644 --- a/src/fs/virtfs/virtfs1_unittest.cc +++ b/src/fs/virtfs/virtfs1_unittest.cc @@ -24,7 +24,7 @@ #include "fs/virtfs/direntry.h" #include "fs/virtfs/virtfs.h" -#include "fs/virtfs/virtfsrwops.h" +#include "fs/virtfs/rwops.h" #include "fs/virtfs/virtlist.h" #include "utils/checkutils.h" diff --git a/src/fs/virtfs/virtfsrwops.cpp b/src/fs/virtfs/virtfsrwops.cpp deleted file mode 100644 index 48a446928..000000000 --- a/src/fs/virtfs/virtfsrwops.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2013-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* - * This code provides a glue layer between PhysicsFS and Simple Directmedia - * Layer's (SDL) RWops i/o abstraction. - * - * License: this code is public domain. I make no warranty that it is useful, - * correct, harmless, or environmentally safe. - * - * This particular file may be used however you like, including copying it - * verbatim into a closed-source project, exploiting it commercially, and - * removing any trace of my name from the source (although I hope you won't - * do that). I welcome enhancements and corrections to this file, but I do - * not require you to send me patches if you make changes. This code has - * NO WARRANTY. - * - * Unless otherwise stated, the rest of PhysicsFS falls under the zlib license. - * Please see LICENSE.txt in the root of the source tree. - * - * SDL falls under the LGPL license. You can get SDL at http://www.libsdl.org/ - * - * This file was written by Ryan C. Gordon. (icculus@icculus.org). - * - * Copyright (C) 2012-2017 The ManaPlus Developers - */ - -#include "fs/virtfs/virtfsrwops.h" - -#include "logger.h" - -#include "fs/virtfs/file.h" -#include "fs/virtfs/virtfs.h" -#include "fs/virtfs/fsfuncs.h" - -#include "utils/fuzzer.h" - -#include - -#include "debug.h" - -namespace VirtFs -{ - -SDL_RWops *create_rwops(File *const file) -{ - SDL_RWops *retval = nullptr; - - if (!file) - { - logger->assertLog("VirtFs::rwops_seek: create rwops error."); - } - else - { - retval = SDL_AllocRW(); - if (retval) - { -#ifdef USE_SDL2 - retval->size = file->funcs->rwops_size; -#endif // USE_SDL2 - - retval->seek = file->funcs->rwops_seek; - retval->read = file->funcs->rwops_read; - retval->write = file->funcs->rwops_write; - retval->close = file->funcs->rwops_close; - retval->hidden.unknown.data1 = file; - } /* if */ - } /* else */ - - return retval; -} /* VirtFs::create_rwops */ - -#ifdef __APPLE__ -static bool checkFilePath(const std::string &restrict fname) -{ - if (fname.empty()) - return false; - if (!exists(fname) || isDirectory(fname)) - return false; - return true; -} -#endif // __APPLE__ - -SDL_RWops *rwopsOpenRead(const std::string &restrict fname) -{ - BLOCK_START("RWopsopenRead") -#ifdef __APPLE__ - if (!checkFilePath(fname)) - return nullptr; -#endif // __APPLE__ -#ifdef USE_FUZZER - if (Fuzzer::conditionTerminate(fname)) - return nullptr; -#endif // USE_FUZZER -#ifdef USE_PROFILER - - SDL_RWops *const ret = create_rwops(openRead(fname)); - - BLOCK_END("RWopsopenRead") - return ret; -#else // USE_PROFILER - - return create_rwops(openRead(fname)); -#endif // USE_PROFILER -} /* RWopsopenRead */ - -SDL_RWops *rwopsOpenWrite(const std::string &restrict fname) -{ -#ifdef __APPLE__ - if (!checkFilePath(fname)) - return nullptr; -#endif // __APPLE__ - - return create_rwops(openWrite(fname)); -} /* RWopsopenWrite */ - -SDL_RWops *rwopsOpenAppend(const std::string &restrict fname) -{ -#ifdef __APPLE__ - if (!checkFilePath(fname)) - return nullptr; -#endif // __APPLE__ - - return create_rwops(openAppend(fname)); -} /* RWopsopenAppend */ - -} // namespace VirtFs - -/* end of virtfsrwops.c ... */ diff --git a/src/fs/virtfs/virtfsrwops.h b/src/fs/virtfs/virtfsrwops.h deleted file mode 100644 index 7be265ad2..000000000 --- a/src/fs/virtfs/virtfsrwops.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2013-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* - * This code provides a glue layer between PhysicsFS and Simple Directmedia - * Layer's (SDL) RWops i/o abstraction. - * - * License: this code is public domain. I make no warranty that it is useful, - * correct, harmless, or environmentally safe. - * - * This particular file may be used however you like, including copying it - * verbatim into a closed-source project, exploiting it commercially, and - * removing any trace of my name from the source (although I hope you won't - * do that). I welcome enhancements and corrections to this file, but I do - * not require you to send me patches if you make changes. This code has - * NO WARRANTY. - * - * Unless otherwise stated, the rest of PhysicsFS falls under the zlib license. - * Please see LICENSE.txt in the root of the source tree. - * - * SDL falls under the LGPL license. You can get SDL at http://www.libsdl.org/ - * - * This file was written by Ryan C. Gordon. (icculus@icculus.org). - * - * Copyright (C) 2012-2017 The ManaPlus Developers - */ - -#ifndef SRC_FS_VIRTFSRWOPS_H -#define SRC_FS_VIRTFSRWOPS_H - -#include "localconsts.h" - -#include - -struct SDL_RWops; - -namespace VirtFs -{ - struct File; - - SDL_RWops *create_rwops(File *const file); - - SDL_RWops *rwopsOpenRead(const std::string &restrict fname); - SDL_RWops *rwopsOpenWrite(const std::string &restrict fname) A_WARN_UNUSED; - SDL_RWops *rwopsOpenAppend(const std::string &restrict fname) - A_WARN_UNUSED; -} // namespace VirtFs - -#endif // SRC_FS_VIRTFSRWOPS_H diff --git a/src/integrity_unittest.cc b/src/integrity_unittest.cc index 41a57f41d..955c0457f 100644 --- a/src/integrity_unittest.cc +++ b/src/integrity_unittest.cc @@ -28,7 +28,7 @@ #include "fs/files.h" #include "fs/virtfs/virtfs.h" -#include "fs/virtfs/virtfsrwops.h" +#include "fs/virtfs/rwops.h" #include "gui/gui.h" diff --git a/src/resources/atlas/atlasmanager.cpp b/src/resources/atlas/atlasmanager.cpp index 7b7ab4536..8a9991714 100644 --- a/src/resources/atlas/atlasmanager.cpp +++ b/src/resources/atlas/atlasmanager.cpp @@ -28,7 +28,7 @@ #include "logger.h" #endif // DEBUG_IMAGES -#include "fs/virtfs/virtfsrwops.h" +#include "fs/virtfs/rwops.h" #include "utils/mathutils.h" #include "utils/sdlcheckutils.h" diff --git a/src/resources/loaders/imageloader.cpp b/src/resources/loaders/imageloader.cpp index 5ae883886..268466654 100644 --- a/src/resources/loaders/imageloader.cpp +++ b/src/resources/loaders/imageloader.cpp @@ -22,7 +22,7 @@ #include "resources/imagehelper.h" -#include "fs/virtfs/virtfsrwops.h" +#include "fs/virtfs/rwops.h" #include "resources/image/image.h" diff --git a/src/resources/loaders/musicloader.cpp b/src/resources/loaders/musicloader.cpp index 1e5ceaff7..3c6c7e1c2 100644 --- a/src/resources/loaders/musicloader.cpp +++ b/src/resources/loaders/musicloader.cpp @@ -22,7 +22,7 @@ #include "resources/sdlmusic.h" -#include "fs/virtfs/virtfsrwops.h" +#include "fs/virtfs/rwops.h" #include "resources/loaders/musicloader.h" diff --git a/src/resources/loaders/soundloader.cpp b/src/resources/loaders/soundloader.cpp index 819e3d140..bbab6d6ee 100644 --- a/src/resources/loaders/soundloader.cpp +++ b/src/resources/loaders/soundloader.cpp @@ -22,7 +22,7 @@ #include "resources/soundeffect.h" -#include "fs/virtfs/virtfsrwops.h" +#include "fs/virtfs/rwops.h" #include "resources/loaders/soundloader.h" diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp index ffb183cd0..64ea181fb 100644 --- a/src/test/testlauncher.cpp +++ b/src/test/testlauncher.cpp @@ -26,7 +26,7 @@ #include "settings.h" #include "soundmanager.h" -#include "fs/virtfs/virtfsrwops.h" +#include "fs/virtfs/rwops.h" #include "gui/skin.h" #include "gui/theme.h" -- cgit v1.2.3-70-g09d2