Commit graph

105 commits

Author SHA1 Message Date
Hamish Milne
7049af744f Merge remote-tracking branch 'upstream/master' into feature/savestates-2 2020-03-28 12:33:21 +00:00
Vitor K
480d3aaf19
common: Port some changes from dolphin (#5127)
* IOFile: Make the move constructor and move assignment operator noexcept

Certain parts of the standard library try to determine whether or not a
transfer operation should either be a copy or a move. The prevalent notion
of move constructors/assignment operators is that they should not throw,
they simply move an already existing resource somewhere else.

This is typically done with 'std::move_if_noexcept'. Like the name says,
if a type's move constructor is noexcept, then the functions retrieves an
r-value reference (for move semantics), or an l-value (for copy semantics)
if it is not noexcept.

As IOFile deletes the copy constructor and copy assignment operators,
using IOFile with certain parts of the standard library can fail in
unexcepted ways (especially when used with various container
implementations). This prevents that.

* fix various instances of -1 being assigned to unsigned types

* do not assign in conditional statements

* File/IOFile: Check _tfopen_s properly

* common/file_util.cpp: address review comments

Co-authored-by: Lioncash <mathew1800@gmail.com>
Co-authored-by: Shawn Hoffman <godisgovernment@gmail.com>
Co-authored-by: Sepalani <sepalani@hotmail.fr>
2020-03-25 14:33:37 -05:00
zhupengfei
a487016cb4
core, citra_qt: Implement a save states file format and slot UI
10 slots are offered along with 'Save to Oldest Slot' and 'Load from Newest Slot'.

The savestate format is similar to the movie file format. It is called CST (Citra SavesTate), and is basically a 0x100 byte header (consisting of magic, revision, creation time and title ID) followed by Zstd compressed raw savestate data.

The savestate files are saved to the `states` folder in Citra's user folder. The files are named like `<Title ID>.<Slot ID>.cst`.
2020-02-18 13:19:52 +08:00
Hamish Milne
2217b3558d Fixed file services serialization 2020-02-13 17:42:10 +08:00
Hamish Milne
996aba39fe Correct exports; add some file serialization; fix service base object serialization 2020-02-13 17:42:07 +08:00
James Rowe
cf4125a6a5 Only load precompiled shaders if their sanitize_mul setting matches 2020-01-15 21:10:37 -07:00
James Rowe
6945b6539f Address review and update zstd 2020-01-15 19:58:34 -07:00
James Rowe
be52d3a7d0 Add missing changes from yuzu file_util 2020-01-15 19:58:34 -07:00
Khangaroo
ae4aaf2fc1 nested folder support + refuse to load incompatibly sized textures + general cleanups 2019-11-09 12:56:27 -07:00
Khangaroo
6d90c42a79 fix crashes, add custom texture cache, load textures from load directory 2019-11-09 12:54:40 -07:00
khang06
94b3c63bf9 add dump dir to user paths 2019-11-09 12:53:16 -07:00
xperia64
8131bd32e3 renderer_opengl: Add support for custom shaders (#4578)
* Add Anaglyph 3D

Change 3D slider in-game

Change shaders while game is running

Move shader loading into function

Disable 3D slider setting when stereoscopy is off

The rest of the shaders

Address review issues

Documentation and minor fixups

Forgot clang-format

Fix shader release on SDL2-software rendering

Remove unnecessary state changes

Respect 3D factor setting regardless of stereoscopic rendering

Improve shader resolution passing

Minor setting-related improvements

Add option to toggle texture filtering

Rebase fixes

* One final clang-format

* Fix OpenGL problems
2019-08-09 20:00:47 +02:00
bunnei
bf8224213d android: common: file_util: Add user_path, ConfigDir, and CacheDir. 2019-07-07 11:01:13 -04:00
Tobias
ef73de9386
Port yuzu-emu/yuzu#2511: "common/file_util: Minor cleanup" (#4782)
* common/file_util: Make IOFile's WriteString take a std::string_view

We don't need to force the usage of a std::string here, and can instead
use a std::string_view, which allows writing out other forms of strings
(e.g. C-style strings) without any unnecessary heap allocations.

* common/file_util: Remove unnecessary c_str() calls

The file stream open functions have supported std::string overloads
since C++11, so we don't need to use c_str() here. Same behavior, less
code.

* common/file_util: Make ReadFileToString and WriteStringToFile consistent

Makes the parameter ordering consistent, and also makes the filename
parameter a std::string. A std::string would be constructed anyways with
the previous code, as IOFile's only constructor with a filepath is one
taking a std::string.

We can also make WriteStringToFile's string parameter utilize a
std::string_view for the string, making use of our previous changes to
IOFile.

* common/file_util: Remove duplicated documentation comments

These are already present within the header, so they don't need to be
repeated in the cpp file.

* common/file_util: Make GetCurrentDir() return a std::optional

nullptr was being returned in the error case, which, at a glance may
seem perfectly OK... until you realize that std::string has the
invariant that it may not be constructed from a null pointer. This
means that if this error case was ever hit, then the application would
most likely crash from a thrown exception in std::string's constructor.

Instead, we can change the function to return an optional value,
indicating if a failure occurred.

* common/file_util: Remove unnecessary return at end of void StripTailDirSlashes()

While we're at it, also invert the conditional into a guard clause.
2019-06-08 00:23:57 +02:00
BreadFish64
605dfe80e7 appease clang format 2019-03-09 19:15:35 -06:00
BreadFish64
9848610ea2 android: init user path 2019-03-09 18:23:27 -06:00
BreadFish64
d3d53bae83 common: decouple getting and setting user paths
paths -> g_paths
2019-02-15 14:48:31 -06:00
B3N30
847003cc1c FFmpegDL: Added external_dlls folder to user folder
AACDecoder: addressed reviews
2019-02-09 11:52:31 +01:00
Ben
b90ff739a0 Add CheatEngine and support for Gateway cheats (#4406)
* Add CheatEngine; Add support for Gateway cheats; Add Cheat UI

* fix a potential crash on some systems

* fix substr with negative length

* Add Joker to the NonOp comp handling

* Fixup JokerOp

* minor fixup in patchop; add todo for nested loops

* Add comment for PadState member variable in HID

* fix: stol to stoul in parsing cheat file

* fix misplaced parsing of values; fix patchop code

* add missing break

* Make read_func and write_func a template parameter
2018-11-16 18:01:10 -07:00
Weiyi Wang
25a370ef19 only redefine 64 bit file operation for MSVC
MinGW provides POSIX functions
2018-10-13 13:21:18 -04:00
Lioncash
b3221c3180 file_util: Use an enum class for GetUserPath()
Instead of using an unsigned int as a parameter and expecting a user to
always pass in the correct values, we can just convert the enum into an
enum class and use that type as the parameter type instead, which makes
the interface more type safe.

We also get rid of the bookkeeping "NUM_" element in the enum by just
using an unordered map. This function is generally low-frequency in
terms of calls (and I'd hope so, considering otherwise would mean we're
slamming the disk with IO all the time) so I'd consider this acceptable
in this case.
2018-09-22 21:18:56 +02:00
Weiyi Wang
7d8f115185 Prefix all size_t with std::
done automatically by executing regex replace `([^:0-9a-zA-Z_])size_t([^0-9a-zA-Z_])` -> `$1std::size_t$2`
2018-09-06 16:03:28 -04:00
Ben
d5333c37de
Merge pull request #4033 from zhaowenlan1779/port-yuzu-764
Port "file_util: Minor changes to ScanDirectoryTree() and ForeachDirectoryEntry()" from yuzu
2018-07-30 13:51:21 +02:00
Merry
c4c158c6b6
Merge pull request #4036 from zhaowenlan1779/port-yuzu-705
Port "file_util: return string by const reference for GetExeDirectory()" from yuzu
2018-07-30 12:10:35 +01:00
Lioncash
99b2a871a7 file_util: return string by const reference for GetExeDirectory()
This disallows modifying the internal string buffer (which shouldn't be
modified anyhow).
2018-07-30 16:55:55 +08:00
Lioncash
df5069f8c0 file_util: Use a u64 to represent number of entries
This avoids a truncating cast on size. I doubt we'd ever traverse a
directory this large, however we also shouldn't truncate sizes away.
2018-07-30 16:19:03 +08:00
Lioncash
cc6cb45536 file_util: std::move FST entries in ScanDirectoryTree()
Avoids unnecessary copies when building up the FST entries.
2018-07-30 16:16:58 +08:00
Lioncash
d3a52e45e3 file_util: Remove goto usages from Copy()
We can just leverage std::unique_ptr to automatically close these for us
in error cases instead of jumping to the end of the function to call
fclose on them.
2018-07-30 08:48:58 +08:00
wwylele
0eab948728 reformat all files with clang-format 2018-06-29 16:56:12 +03:00
wwylele
7c5a76e58b log: replace all NGLOG with LOG 2018-06-29 14:18:07 +03:00
Daniel Lim Wee Soong
51398e0301 Logging: Add customizable logging backends and fmtlib based macros
* Change the logging backend to support multiple sinks through the
Backend Interface
* Add a new set of logging macros to use fmtlib instead.
* Qt: Compile as GUI application on windows to make the console hidden by
default. Add filter configuration and a button to open log location.
* SDL: Migrate to the new logging macros
2018-04-23 21:32:56 -06:00
wwylele
39fce60145 [quick-fix]file-util: fmtlib errors on FILE* type parameter. Explicitly cast it to void* 2018-04-06 13:35:37 +03:00
Daniel Lim Wee Soong
0f4c9c9f47 file_util: Remove long long casting on buf.st_size in NGLOG statement 2018-03-27 23:31:08 +08:00
Daniel Lim Wee Soong
968569aa61 Replace format specifiers for all usages of ASSERT_MSG 2018-03-27 23:28:42 +08:00
Daniel Lim Wee Soong
111da6db06 common: Migrate logging macros
Follow-up of #3533

Replace logging to use NGLOG instead of LOG

This is significantly larger than the previous ones.
2018-03-25 18:42:50 +08:00
James Rowe
f61141e86a Update the entire application to use the new clang format style 2018-03-09 10:54:43 -07:00
wwylele
d040a73bed file_util: Log when using local user directory 2017-03-11 18:31:17 +02:00
wwylele
7cd6cc0fd9 file_util: lower logging level for harmless cases 2017-03-08 17:42:10 +02:00
noah the goodra
a2d0e2d807 file_util: Fixed implicit type conversion warning (#2503) 2017-01-30 20:08:00 -08:00
wwylele
488b7a4041 file_util: fix missing sysdata path 2016-12-23 22:19:14 +02:00
bunnei
707cc66362 file_util: Remove unused paths. 2016-12-21 23:29:12 -05:00
Jeffrey Pfau
fb952c399e Common: Fix gcc build on macOS 2016-12-13 10:20:33 -08:00
freiro
0c22e52f52 WINVER definition moved to CMake and cleanup 2016-11-30 15:47:09 +01:00
freiro
972b289c78 Removed /user/ from path 2016-11-26 01:00:52 +01:00
freiro
79317b63d9 Switch to AppData/Roaming 2016-11-24 16:42:31 +01:00
freiro
3d75e3cd07 Return by value and other fixes 2016-11-19 15:50:16 +01:00
freiro
29bb82cb8e Win32 move default user folder location to AppData 2016-11-19 15:49:52 +01:00
Anthony J. Bentley
26af2b644c common: convert to standard stat()/fstat() interfaces
Most modern Unix environments use 64-bit off_t by default: OpenBSD,
FreeBSD, OS X, and Linux libc implementations such as Musl.

glibc is the lone exception; it can default to 32 bits but this is
configurable by setting _FILE_OFFSET_BITS.

Avoiding the stat64()/fstat64() interfaces is desirable because they
are nonstandard and not implemented on many systems (including
OpenBSD and FreeBSD), and using 64 bits for stat()/fstat() is either
the default or trivial to set up.
2016-10-27 23:28:30 +00:00
Jan Beich
51f92f0e4e common: stat64 is non-standard, hide on a random Unix
src/common/file_util.cpp:79:19: error: variable has incomplete type 'struct stat64'
    struct stat64 file_info;
                  ^
src/common/file_util.cpp:79:12: note: forward declaration of 'stat64'
    struct stat64 file_info;
           ^
src/common/file_util.cpp:99:19: error: variable has incomplete type 'struct stat64'
    struct stat64 file_info;
                  ^
src/common/file_util.cpp:99:12: note: forward declaration of 'stat64'
    struct stat64 file_info;
           ^
src/common/file_util.cpp:342:19: error: variable has incomplete type 'struct stat64'
    struct stat64 buf;
                  ^
src/common/file_util.cpp:342:12: note: forward declaration of 'stat64'
    struct stat64 buf;
           ^
src/common/file_util.cpp:359:19: error: variable has incomplete type 'struct stat64'
    struct stat64 buf;
                  ^
src/common/file_util.cpp:359:12: note: forward declaration of 'stat64'
    struct stat64 buf;
           ^
4 errors generated.
2016-10-27 23:28:29 +00:00
Yuri Kunde Schlesner
f120e78b56 Remove special rules for Windows.h and library includes 2016-09-21 00:16:33 -07:00