Set OakDocument’s ‘onDisk’ property during initialization

The old implementation in document_t would check the status in the getter when the document wasn’t open, since we only observe the disk for open documents.

Such solution though would not support key/value observing.

We could improve performance slightly by accepting an “isOnDisk” flag in the initializer since when we create documents from scanning the disk (folder search and file chooser) we already know the document is on disk and thus could skip the extra disk access.
This commit is contained in:
Allan Odgaard
2016-06-27 11:44:45 +02:00
parent 3f44309466
commit 1b7e37affa

View File

@@ -319,7 +319,8 @@ private:
{
if(self = [self init])
{
_path = aPath;
_path = aPath;
_onDisk = access([_path fileSystemRepresentation], F_OK) == 0;
}
return self;
}
@@ -355,6 +356,7 @@ private:
_backupPath = to_ns(path);
_path = to_ns(path::resolve(path::get_attr(path, "com.macromates.backup.path")));
_onDisk = access([_path fileSystemRepresentation], F_OK) == 0;
_fileType = to_ns(path::get_attr(path, "com.macromates.backup.file-type"));
_diskEncoding = to_ns(path::get_attr(path, "com.macromates.backup.encoding"));
_diskNewlines = to_ns(path::get_attr(path, "com.macromates.backup.newlines"));