Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/.PVS-Studio
/build
5 changes: 5 additions & 0 deletions .idea/dictionaries/project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/runConfigurations/Run_Tests.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ set(ZLIB_USE_STATIC_LIBS ON)
find_package(ZLIB REQUIRED)
find_path(ZSTR_INCLUDE_DIRS "zstr.hpp")
find_package(Python3 COMPONENTS Development REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(xxHash CONFIG REQUIRED)

set(ALL_MODULES renpy rpgmaker zanzarah)
set(RELEASED_MODULES renpy zanzarah)
Expand All @@ -41,6 +43,24 @@ foreach (module IN LISTS ALL_MODULES)
set_target_properties(${module} PROPERTIES SUFFIX ".so" PREFIX "" LINK_FLAGS "/DEF:${CMAKE_CURRENT_SOURCE_DIR}/src/modules/${module}/${module}.def")
endforeach ()

# === CTest ===

find_package(Catch2 REQUIRED)
add_executable(tests
src/tests/framework/observer.cpp
src/tests/framework/testcase.cpp
src/tests/renpy.cpp
src/tests/zanzarah.cpp)
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain)
target_link_libraries(tests PRIVATE nlohmann_json::nlohmann_json)
target_link_libraries(tests PRIVATE xxHash::xxhash)
target_link_libraries(tests PRIVATE ${ALL_MODULES})
include(CTest)
include(Catch)
catch_discover_tests(tests)

# === CPack ===

file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/docs_temp/thirdparty)
file(COPY ${CMAKE_SOURCE_DIR}/licenses/ DESTINATION ${CMAKE_BINARY_DIR}/docs_temp/thirdparty)

Expand Down
827 changes: 668 additions & 159 deletions LICENSE.txt

Large diffs are not rendered by default.

31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Refaim's Observer Modules for FAR Manager

[![License: LGPL v3](https://img.shields.io/badge/License-LGPL_v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![CI](https://github.com/refaim/ObserverModules/actions/workflows/main.yml/badge.svg)](https://github.com/refaim/ObserverModules/actions/workflows/main.yml)

## About the Project
Expand Down Expand Up @@ -54,16 +54,25 @@ specific files as needed without having to unpack the entire archive.

[Support Forum (in Russian)](https://forum.farmanager.com/viewtopic.php?t=12729)

## Dependencies and Third-Party Code

| Project | License |
|------------------------------------------------------|---------------------------------|
| [Observer](https://github.com/lazyhamster/Observer/) | [LGPLv3](licenses/Observer.txt) |
| [Python](https://www.python.org/) | [PSF](licenses/Python.txt) |
| [rpatool](https://github.com/Shizmob/rpatool/) | [WTFPL](licenses/rpatool.txt) |
| [rgssad](https://github.com/luxrck/rgssad) | [MIT](licenses/rgssad.txt) |
| [zlib](https://zlib.net/) | [zlib](licenses/zlib.txt) |
| [zstr](https://github.com/mateidavid/zstr) | [MIT](licenses/zstr.txt) |
## Third-party components

| Project | License |
|-----------------------------------------------------|-------------------------------------|
| [json](https://github.com/nlohmann/json) | [MIT](licenses/json.txt) |
| [Catch2](https://github.com/catchorg/Catch2) | [BSL-1.0](licenses/Boost.txt) |
| [Observer](https://github.com/lazyhamster/Observer) | [LGPL-3.0](licenses/Observer.txt) |
| [Python](https://www.python.org) | [PSF-2.0](licenses/Python.txt) |
| [xxHash](https://github.com/Cyan4973/xxHash) | [BSD-2-Clause](licenses/xxHash.txt) |
| [zlib](https://zlib.net) | [zlib](licenses/zlib.txt) |
| [zstr](https://github.com/mateidavid/zstr) | [MIT](licenses/zstr.txt) |

## Sources of inspiration

| Project | License |
|------------------------------------------------------------------|----------------------------------|
| [rgssad](https://github.com/luxrck/rgssad) | [MIT](licenses/rgssad.txt) |
| [rpatool](https://github.com/Shizmob/rpatool) | [WTFPL](licenses/rpatool.txt) |
| [zanzapak](https://aluigi.altervista.org/papers.htm#others-file) | [GPL-3.0](licenses/zanzapak.txt) |

## Building from Source

Expand Down
23 changes: 23 additions & 0 deletions licenses/Catch2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
21 changes: 21 additions & 0 deletions licenses/json.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2013-2025 Niels Lohmann

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
26 changes: 26 additions & 0 deletions licenses/xxHash.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
xxHash Library
Copyright (c) 2012-2021 Yann Collet
All rights reserved.

BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php)

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 changes: 17 additions & 0 deletions licenses/zanzapak.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Copyright 2005,2006 Luigi Auriemma

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
(at your option) 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, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

http://www.gnu.org/licenses/gpl.txt
10 changes: 6 additions & 4 deletions src/api.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#ifndef API_H
#define API_H
#pragma once

/**
This file is licensed under the GNU LGPLv3.
It includes/modifies code originally from Observer (https://github.com/lazyhamster/Observer).
**/

// The following macros define the minimum required platform. The minimum required platform
// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
Expand Down Expand Up @@ -147,5 +151,3 @@ typedef void (MODULE_EXPORT *UnloadSubModuleFunc)(void);
#define SER_ERROR_SYSTEM 3
#define SER_USERABORT 4
#define SER_PASSWORD_REQUIRED 5

#endif
5 changes: 1 addition & 4 deletions src/archive.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ZANZARAH_H
#define ZANZARAH_H
#pragma once

#include "modules/extractor.h"

Expand Down Expand Up @@ -54,5 +53,3 @@ namespace archive
std::vector<std::unique_ptr<extractor::file> > files_;
};
}

#endif
3 changes: 3 additions & 0 deletions src/dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ extern "C" int MODULE_EXPORT GetItem(HANDLE storage, int item_index, StorageItem
item_info->Attributes = FILE_ATTRIBUTE_NORMAL;
item_info->Size = header_size + file.uncompressed_body_size_in_bytes;
item_info->PackedSize = header_size + file.compressed_body_size_in_bytes;
item_info->NumHardlinks = 0;
const auto chars_written = MultiByteToWideChar(CP_UTF8, 0, file.path.c_str(), -1, item_info->Path,
static_cast<int>(std::size(item_info->Path)));
if (chars_written == 0) {
Expand Down Expand Up @@ -124,6 +125,8 @@ extern "C" int MODULE_EXPORT ExtractItem(HANDLE storage, ExtractOperationParams
return SER_ERROR_WRITE;
} catch (std::runtime_error &) {
return SER_ERROR_SYSTEM;
} catch (std::logic_error &) {
return SER_ERROR_SYSTEM;
}

return SER_SUCCESS;
Expand Down
5 changes: 1 addition & 4 deletions src/modules/extractor.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef EXTRACTOR_H
#define EXTRACTOR_H
#pragma once

#include <memory>
#include <span>
Expand Down Expand Up @@ -60,5 +59,3 @@ namespace extractor
std::vector<std::unique_ptr<file> > list_files(std::ifstream &stream);
};
}

#endif
5 changes: 1 addition & 4 deletions src/modules/renpy/python/_ref.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef REF_H
#define REF_H
#pragma once

#include "python.h"

Expand Down Expand Up @@ -82,5 +81,3 @@ namespace python
return dynamic_cast<const ref &>(object).get();
}
}

#endif
5 changes: 1 addition & 4 deletions src/modules/renpy/python/python.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef PYTHON_H
#define PYTHON_H
#pragma once

#include <generator>
#include <memory>
Expand Down Expand Up @@ -87,5 +86,3 @@ namespace python
[[nodiscard]] std::generator<std::pair<std::string_view, std::unique_ptr<object> > > iterate() const;
};
}

#endif
30 changes: 30 additions & 0 deletions src/tests/framework/make_listing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import json
import os
import sys

from pathlib import Path

import xxhash

items = []
output_name = "expected.json"
root = Path(sys.argv[1])
for current_folder, folder_names, file_names in os.walk(str(root)):
for file_name in file_names:
if file_name != output_name:
file = Path(current_folder) / file_name

checksum = xxhash.xxh3_64()
with file.open('rb') as file_object:
checksum.update(file_object.read())

strings = [
str(file.relative_to(root)),
str(file.stat().st_size),
checksum.hexdigest(),
]

items.append(" ".join(strings))

with open(root.joinpath(output_name), "w", encoding="utf-8") as output:
json.dump(sorted(items), output, indent=4, ensure_ascii=False)
Loading