void ntfsCloseFile(ntfs_file_state *file) { // Sanity check if (!file || !file->vd) return; // Special case fix ups for compressed and/or encrypted files if (file->compressed) ntfs_attr_pclose(file->data_na); #ifdef HAVE_SETXATTR if (file->encrypted) ntfs_efs_fixup_attribute(NULL, file->data_na); #endif // Close the file data attribute (if open) if (file->data_na) ntfs_attr_close(file->data_na); // Sync the file (and its attributes) to disc if (file->write) { ntfsUpdateTimes(file->vd, file->ni, NTFS_UPDATE_ATIME | NTFS_UPDATE_CTIME); ntfsSync(file->vd, file->ni); } if (file->read) ntfsUpdateTimes(file->vd, file->ni, NTFS_UPDATE_ATIME); // Close the file (if open) if (file->ni) ntfsCloseEntry(file->vd, file->ni); // Reset the file state file->ni = NULL; file->data_na = NULL; file->flags = 0; file->read = false; file->write = false; file->append = false; file->pos = 0; file->len = 0; return; }
void ntfsCloseFile (ntfs_file_state *file) { // Sanity check if (!file || !file->vd) return; // Special case fix ups for compressed and/or encrypted files if (file->compressed) ntfs_attr_pclose(file->data_na); if (file->encrypted) ntfs_efs_fixup_attribute(NULL, file->data_na); // Close the file data attribute (if open) if (file->data_na) ntfs_attr_close(file->data_na); // Sync the file (and its attributes) to disc if(file->write) ntfsSync(file->vd, file->ni); // Close the file (if open) if (file->ni) ntfsCloseEntry(file->vd, file->ni); // Reset the file state file->ni = NULL; file->data_na = NULL; file->flags = 0; file->read = false; file->write = false; file->append = false; file->pos = 0; file->len = 0; return; }