129 Commits

Author SHA1 Message Date
Allan Odgaard
77bc9f7a6f Remove test for localized folder names as it does not work (10.14)
I cannot find any information online about Apple dropping support for this, but I also cannot make it work, and it wouldn’t surprise me if they view localized folder names as a security problem.
2019-07-16 20:02:42 +02:00
Allan Odgaard
f21d570b73 Remove test for VOL_CAP_INT_EXCHANGEDATA
This is no longer supported (with APFS) so there is no reason to keep this code around.
2019-07-16 14:29:20 +02:00
Allan Odgaard
087e0ce0a7 Import os/log.h when deployment target is macOS 10.12 or later 2019-07-13 08:22:00 +02:00
Allan Odgaard
a9b5925f57 Saving a file would lose existing file permission flags 2019-07-08 13:07:28 +02:00
Allan Odgaard
58414e9def Resolve potential symbolic link in path to save
Trying to save a file as /path/to/symlink will fail with “file does not exist” using the new NSFileManager API, even when the symbolic link does point to an existing file.
2019-07-08 07:27:36 +02:00
Allan Odgaard
824981eaa2 Produce error string for any failure from saving with NSFileManager 2019-07-07 22:10:11 +02:00
Allan Odgaard
538283cc67 Use NSFileManager’s replaceItemAtURL:… as default way to save atomically
NSFileManager’s approach is inferior to exchangedata(), but as this feature is no longer supported with Apple’s default file system (APFS), there is little reason to maintain our own implementation of the fallback code required when we cannot use exchangedata(), especially as the OS know more about file references (aliases), metadata, and other stuff that should be preserved when writing a new (replacement) file.

In theory the NSFileManager strategy can fail to create the temporary destination, in which case we will pass NULL to open() and crash.

Will fix this in a later commit.
2019-07-07 20:52:50 +02:00
Allan Odgaard
997e70059a Switch to Objective-C for the implementation of atomic saving
The most appropriate API for dealing with temporary files and atomic saving seems to be NSFileManager.
2019-07-07 11:37:59 +02:00
Allan Odgaard
4c4822e1ca Make it easier to change (atomic) saving strategy
The intermediate_t type now wraps the actual saving strategy to make it easier to change strategy based on the destination file system, user preferences, or other factors.
2019-07-07 11:12:16 +02:00
Allan Odgaard
ffba605cc1 Do not call abort for posix_spawn related failures
Based on crash reports, some of these functions do fail in practice, mainly due to “too many open file descriptors”, in which case we should let the io::spawn function fail, rather than crash the program.

The io::spawn function is used (amongst others) to update SCM status, so a failure is not always worth notifying the user about (beyond logging an error).
2018-11-17 11:35:40 +07:00
Allan Odgaard
dfa5bd779e Move path::info to OakFileBrowser
The code is about how to display items in the file browser (package, folder, alias, non-browsable volume, etc.) so it makes sense to limit the visibility of this API.
2018-07-30 22:37:35 +02:00
Allan Odgaard
c4179a22f7 Use path::is_directory in path::make_dir (instead of path::info) 2018-07-30 22:37:35 +02:00
Allan Odgaard
1d008057a4 Don’t call path::info() in path::is_directory
The path::info() function is a bit arcane and best avoided.
2018-07-30 22:37:35 +02:00
Allan Odgaard
42fa47a2fd Remove path::tag_data and let finderTagsFromData: be private 2018-07-08 18:20:17 +02:00
Allan Odgaard
11fa1841b3 Remove all code related to labels 2018-07-08 17:23:53 +02:00
Ronald Wampler
a31a985610 Add support for Finder tags instead of just one label color 2018-07-06 19:41:00 -04:00
Ronald Wampler
d1ecba2629 Use the FSRef API directly and delete fsref_t (10.9)
The textClipping file is saved as a binary plist on 10.11 and 10.12 (I could not verify 10.10) so we can eventually replace the use of FSRef here as well.
2017-05-31 21:58:31 +02:00
Ronald Wampler
a377b35bde Use OakMoveToTrash instead of FSMoveObjectToTrashSync (10.9) 2017-05-31 21:58:31 +02:00
Allan Odgaard
e669722ba2 Remove workaround for changed scandir prototype (10.8) 2016-10-22 23:27:15 +07:00
mathbunnyru
440414f96c Use nullptr in all C++ files instead of NULL
This brings us a bit of extra type safety, for example where an integer is expected, nullptr should be disallowed by the compiler (unlike NULL).
2016-10-22 21:40:14 +07:00
mathbunnyru
d6db299a8f Changed from NULL to nullptr in variadic templates for portability 2016-10-19 00:59:11 +03:00
mathbunnyru
1b4adf29e1 Fixed memory leak 2016-10-18 23:06:49 +02:00
mathbunnyru
284b5a3896 Slight perfomance improvements 2016-10-18 23:06:48 +02:00
mathbunnyru
08ad760d5e static_cast instead of c-style cast 2016-10-18 23:06:48 +02:00
Allan Odgaard
ee2aee21fa Use oak::has_prefix when comparing std::string against string literal 2016-10-17 11:03:41 +02:00
mathbunnyru
0b034f9a9d Use std::string’s compare to avoid searching beyond the prefix length 2016-10-17 10:50:18 +02:00
Allan Odgaard
2feb4a497a Use crash_reporter_info_t’s convenience constructor
Also change most ‘crashInfo’ variable names to just ‘info’ to be consistent.
2016-10-07 22:14:33 +02:00
Allan Odgaard
c5abbb755b Higher value from path::rank now means better match 2016-09-04 20:17:42 +02:00
Allan Odgaard
fe991f7b4b Improve error message for failure during save 2016-08-29 07:51:45 +02:00
Allan Odgaard
ce21cb8ea4 Make swap_and_unlink a private function 2016-08-29 07:50:43 +02:00
Allan Odgaard
f92a783a96 Introduce path::rename_or_copy
Unlike path::swap_and_unlink we do not try to use exchangedata() since support for this is missing from the upcoming AppleFileSystem, so it would seem to be somewhat deprecated.
2016-08-29 07:48:37 +02:00
Allan Odgaard
4ab38d3cfd Use the S_IRWX[UGO] constants to set file mode 2016-08-28 17:49:17 +02:00
Allan Odgaard
46fb745bbe Use perrorf when printing errors with dynamic strings
Also revise error messages to be more consistent.
2016-08-28 17:25:26 +02:00
Allan Odgaard
b0ba62451d Remove path::touch_tree
This was previously used by the software updater to prevent the “temp cleaner” from removing a downloaded update, incase the user took their time to click the “Install & Relaunch” button.
2016-08-28 09:14:43 +02:00
Allan Odgaard
dbdfa3c6af Add identifying information to perror output 2016-08-21 12:09:30 +02:00
Allan Odgaard
511e1d58a5 Remove old (crash reports) debug info 2016-07-16 13:14:43 +02:00
Ronald Wampler
e50dc57db0 Manually release GCD objects in C++ libraries
Since these are pure C++ libraries, they are not managed by ARC. This commit partially reverts 469fd74a7b.
2016-07-14 12:21:28 +02:00
Allan Odgaard
fdaf7ca732 Remove workaround for OS bug (10.8) 2016-06-22 20:44:41 +02:00
Allan Odgaard
469fd74a7b Rely on ARC to manage GCD types (10.8) 2016-06-22 20:43:28 +02:00
Allan Odgaard
8483826fae Always use '\0' as fill value when creating a string buffer 2016-06-18 10:34:08 +02:00
Allan Odgaard
068855b4e0 Disable deprecation warning for API working on resource forks
There doesn’t seem to be any replacement API for this so while the warning (when building with the 10.8 SDK) may serve as a reminder to update the code, the only possible update I can see is to drop support for reading text clippings.
2015-08-05 12:32:06 +02:00
Allan Odgaard
c75b89c048 Avoid temporary CFStringRef when creating file system CFURLRef 2015-08-05 12:29:24 +02:00
Allan Odgaard
82e5e14ae1 Remove unused function: is_trashed
The intent was to use this to decide if the proxy icon should be hidden but the API used by the function is deprecated on 10.8.
2015-08-05 12:26:17 +02:00
Allan Odgaard
b3478a2628 Use “modern” API to examine and resolve alias files 2015-08-05 12:23:35 +02:00
Allan Odgaard
34b374c185 Avoid two uses of FSRef (which is deprecated from 10.8) 2015-08-05 12:23:29 +02:00
Allan Odgaard
0b70563c73 Add crash log info to track down a bug
Crash is in CFStringGetLength called from _CFURLCreateWithFileSystemPath, so it appears that some sort of malformed string can find its way to this call.
2015-08-05 12:22:50 +02:00
Allan Odgaard
457969788e Use std::tuple for the OS version
This makes compatibility checks simpler, since we can use a single comparison operator.
2015-06-23 22:46:58 +02:00
Allan Odgaard
09dfe50051 Avoid taking the address of compound literals
Clang considers this to be an error, previously we disabled diagnostics for this case, but probably better to adapt our code.
2014-11-30 09:12:07 +07:00
Allan Odgaard
f34a8f28e0 Use CFURL API for getting and setting label color 2014-11-30 05:59:35 +07:00
Allan Odgaard
5b39bdc98b Remove double semi-colons at end of line 2014-11-14 10:21:34 +01:00