Commit Graph

71 Commits

Author SHA1 Message Date
asrelo
cfa9c83d33
Improve fs::PathStartsWith to handle empty strings (#14877)
`""` does not refer to a proper path, and `fs::PathStartsWith(path, "")` should just return `false`. This is also the case in libraries in other languages where I looked, seems to be common.

The new behavior:
* check early, if `prefix` is empty - return if path is empty or not,
* no special processing for when `path` is empty, the function meets characters in `prefix` and returns false anyway.
2024-08-11 20:19:14 +02:00
sfan5
a6121c7f67 Fix path traversal in mainmenu's extract_zip 2024-07-10 22:37:45 +02:00
sfan5
8268c61b9f Make safeWriteToFile safe for thread-concurrent use 2024-06-10 18:49:43 +02:00
sfan5
39fd9b93c3 Introduce proper error handling for file streams 2024-05-14 18:33:08 +02:00
grorp
57b6e74abb
Fix crash if zip file cannot be opened (#14636)
Helped-by: savilli <78875209+savilli@users.noreply.github.com>
2024-05-12 11:46:39 +02:00
sfan5
7e4462e0ac Better handling of temporary folders 2024-04-06 12:10:21 +02:00
sfan5
d307d01b18 Fix tests that rely on UTF-8 literals
and the lowercase function
2024-03-28 16:22:04 +01:00
sfan5
6ca214fefc
Introduce std::string_view into wider use (#14368) 2024-02-17 15:35:33 +01:00
sfan5
4259ac96ea Optimize fs::CopyFileContents on Linux and Windows 2024-02-04 21:23:05 +01:00
sfan5
1ba26d67bd Remove excessive includes from porting.h 2024-01-14 13:17:53 +01:00
Gary Miguel
6eb9269741
Try to fix safeWriteToFile producing empty files on Windows (#14085)
Use win32 APIs to write the temporary file before copying to the final
destination. Because we've observed the final file being empty, we
suspect that std::ostream::flush is not flushing.

Also add a test for it.
2023-12-13 13:15:37 +01:00
sfan5
15445a0fbe Raise and clean up _WIN32_WINNT constant 2023-05-11 22:51:01 +02:00
sfan5
87d509e462
Implement --debugger option to improve UX when debugging crashes (#13157) 2023-01-23 00:19:30 +01:00
Herman Semenov
038da00e79
Code optimizations / refactor (#12704)
Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com>
Co-authored-by: sfan5 <sfan5@live.de>
2022-09-06 11:21:09 +01:00
rubenwardy
06de82fd86 Refactor ModConfiguration 2022-07-14 22:12:54 +01:00
sfan5
0ea8df4d64
Socket-related cleanups
Improve error handling on Windows and reduce the size of the `Address` class
2021-12-29 23:01:26 +01:00
LoneWolfHT
c82ec8b210
Fix compiling on Windows with Visual Studio 2021-10-15 18:16:09 +02:00
sfan5
6de8d77e17 Move instead of copy during content install if possible 2021-10-07 00:20:01 +02:00
sfan5
2d5b7b5fb4 Make fs::extractZipFile thread-safe 2021-10-07 00:20:01 +02:00
sfan5
4feb799b7e Add Windows-specific CreateTempFile() implementation
Once again MSVC is the only compiler not supporting basic POSIX functionality.
2021-09-14 20:45:41 +02:00
sfan5
bbfae0cc67
Dynamic_Add_Media v2 (#11550) 2021-09-09 16:51:35 +02:00
Loic Blot
225d4541ff fix: extractZipFile is not part of Client but more generic.
This solve a crash from mainmenu while extracting the zip
2021-05-06 16:01:52 +02:00
rubenwardy
3a8c37181a
Use consistent temp folder path (#10892) 2021-02-07 15:27:24 +00:00
rubenwardy
4c76239818
Remove dead code (#10845) 2021-01-22 15:09:26 +00:00
sfan5
74762470b2 Fix some minor code issues all over the place 2020-12-24 13:44:54 +01:00
rubenwardy
9ec75d7765
Clean up server-side translations, remove global variable (#10075) 2020-09-16 14:51:11 +01:00
sfan5
2424dfe007
Server pushing media at runtime (#9961) 2020-06-13 19:03:26 +02:00
Loïc Blot
7f545db977 Fix a stringop-truncation GCC warning
```
minetest/src/filesys.cpp:312:10: warning: ‘char* strncpy(char*, const char*, size_t)’ specified bound 10000 equals destination size [-Wstringop-truncation]
   strncpy(argv_data[2], path.c_str(), 10000);
```
2018-12-04 12:39:19 +01:00
stujones11
015e46310a Android: Fix recursive delete (#7882) 2018-11-21 23:06:03 +00:00
Vitaliy
78bd902b9f Really delete things in fs::RecursiveDelete (#7433)
* Really delete things in fs::RecursiveDelete
2018-08-18 11:00:06 +02:00
stujones11
6b72d8d090 Android: Use correct temporary path (#7463) 2018-06-23 22:38:19 +02:00
number Zero
05d93c7fa1 Load files from subfolders in texturepacks
Updated and rebased version of a PR by red-001
2017-11-17 19:23:08 +00:00
Loic Blot
55ab4264dc
Modernize various files
* range-based for loops
* emplace_back instead of push_back
* code style
* C++ headers instead of C headers
* Default operators
* empty stl function
2017-08-18 07:44:52 +02:00
ShadowNinja
f522e7351a Fix RemoveRelatvePathComponents
This used to return "/foo" for "../foo" when it should return the enpty
string (i.e., error removing all relative components).
2016-12-20 17:17:38 +10:00
ShadowNinja
e4ee6548af Fix fs::RemoveRelativePathComponents for paths with a leading dot component
Previously, paths like ./worlds would be resolved to /worlds since the
leading dot was considered just as irrelevant as a dot in the middle of
the path.
2016-11-24 10:38:23 -05:00
gregorycu
c95734654c Use MoveFileEx to rename files on Windows (not rename) 2016-05-01 17:28:16 +10:00
Perttu Ahola
64c060e1f2 filesys: safeWriteToFile(): Remove the target file before rename only on Windows
Removing the target file on other platforms was enabled likely unintentionally
by commit 5f1f1151d3.

This may be the reason why there has been corruption of files on Linux on hard
shutdowns.

Previously I described the problem and this fix in issue #3084.
2016-01-01 18:21:18 +02:00
ShadowNinja
ea2964f5a1 Add seperate cache path
This is set to the XDG cache path where possible.
It's set to the app's cache path on Android.
2015-12-07 13:51:41 -05:00
Diego Martinez
13e100e1d8 Windows: Fix some warnings. 2015-07-09 01:52:28 +02:00
ShadowNinja
3a8c788880 Add mod security
Due to compatibility concerns, this is temporarily disabled.
2015-05-16 18:32:31 -04:00
kwolekr
7220ca906d Tests: Modularize unit testing
Split unit tests into separate files under src/unittest/
Give better unittest diagnostics
Clean up some code
2015-04-26 15:08:54 -04:00
kwolekr
0df736173e Schematics: Prepend mod path to relative schematic filepaths 2015-04-08 00:28:56 -04:00
ShadowNinja
33eed6eb84 Fix fs::GetRecursiveSubPaths trying to get directory lists for files 2014-12-24 17:23:07 -05:00
SmallJoker
2f8fbdb9f5 Rewrite fs:GetDirListing(file) by kahrl 2014-12-10 02:59:10 +10:00
SmallJoker
5229a229a6 Ignore .name directories and files
Signed-off-by: Craig Robbins <kde.psych@gmail.com>
2014-12-10 02:49:02 +10:00
selat
5f1f1151d3 Remove temporary file at safeWriteToFile() 2014-08-16 12:46:48 +02:00
sapier
1cc40c0a7c Add support for Android 2.3+
There have been plenty of ppl involved in creating this version.
I don't wanna mention names as I'm sure I'd forget someone so I
just tell where help has been done:
- The partial android versions done by various ppl
- Testing on different android devices
- reviewing code (especially the in core changes)
- testing controls
- reviewing texts

A big thank you to everyone helping this to be completed!
2014-06-29 18:17:56 +02:00
Kahrl
4e1f50035e Omnicleanup: header cleanup, add ModApiUtil shared between game and mainmenu 2013-08-14 21:03:33 +02:00
PilzAdam
d718b0b34e Dont write directly to files but rather write and copy a tmp file 2013-08-13 22:05:45 +02:00
Kahrl
2ed3067bbe Fix various memory access problems detected by valgrind 2013-08-07 19:48:31 +02:00