diff --git a/BREAKING-CHANGES.txt b/BREAKING-CHANGES.txt index b35a6d1835..98d6f5bc83 100644 --- a/BREAKING-CHANGES.txt +++ b/BREAKING-CHANGES.txt @@ -4,6 +4,26 @@ JUCE breaking changes Develop ======= +Change +----- +Allow renaming and deletion of open file handles on Windows using the +FILE_SHARE_DELETE flag. + +Possible Issues +--------------- +Previous code that relied on open files not being able to be renamed or +deleted on Windows may fail. + +Workaround +---------- +No workaround. + +Rationale +--------- +This unifies the behaviour across OSes as POSIX systems already allow +this. + + Change ----- Multiple changes to low-level, non-public JNI and Android APIs. diff --git a/modules/juce_core/native/juce_win32_Files.cpp b/modules/juce_core/native/juce_win32_Files.cpp index 481b3dee94..9fd1e9378e 100644 --- a/modules/juce_core/native/juce_win32_Files.cpp +++ b/modules/juce_core/native/juce_win32_Files.cpp @@ -287,7 +287,7 @@ int64 juce_fileSetPosition (void* handle, int64 pos) void FileInputStream::openHandle() { auto h = CreateFile (file.getFullPathName().toWideCharPointer(), - GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, + GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, 0); if (h != INVALID_HANDLE_VALUE) @@ -398,7 +398,7 @@ void MemoryMappedFile::openInternal (const File& file, AccessMode mode, bool exc } auto h = CreateFile (file.getFullPathName().toWideCharPointer(), accessMode, - exclusive ? 0 : (FILE_SHARE_READ | (mode == readWrite ? FILE_SHARE_WRITE : 0)), 0, + exclusive ? 0 : (FILE_SHARE_READ | FILE_SHARE_DELETE | (mode == readWrite ? FILE_SHARE_WRITE : 0)), 0, createType, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, 0); if (h != INVALID_HANDLE_VALUE)