-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Windows: Add support for returning file IDs from
stat
and readdir
* Add `FileInfo.getKey()` that returns a file identifier than can be used to compare efficiently files for equality. If the key is not available, the method returns `null`. * This is a similar concept as exposed in the Java 7 nio API https://docs.oracle.com/javase/7/docs/api/java/nio/file/attribute/BasicFileAttributes.html#fileKey() * A WindowsFileKey is a pair of (volume serial number, file id on the volume) * Update the `stat` and `fastReaddirXxx` jni entry points to provide this information * Update the test app to display `file key` if it is available
- Loading branch information
Showing
13 changed files
with
222 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/net/rubygrapefruit/platform/internal/WindowsFileKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package net.rubygrapefruit.platform.internal; | ||
|
||
final class WindowsFileKey { | ||
private final int volumeId; | ||
private final long fileId; | ||
|
||
WindowsFileKey(int volumeId, long fileId) { | ||
this.volumeId = volumeId; | ||
this.fileId = fileId; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return (int)(volumeId * 31 + fileId); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == this) | ||
return true; | ||
if (!(obj instanceof WindowsFileKey)) | ||
return false; | ||
|
||
WindowsFileKey other = (WindowsFileKey) obj; | ||
return (this.volumeId == other.volumeId) && | ||
(this.fileId == other.fileId); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("(volumeId=") | ||
.append(Integer.toHexString(volumeId)) | ||
.append(",fileId=") | ||
.append(Long.toHexString(fileId)) | ||
.append(')'); | ||
return sb.toString(); | ||
} | ||
} |
Oops, something went wrong.