java


java.nio.file.Path error with VSS (Volume Shadow Copy) paths


Using VSS, I've created a volume snapshot and can successfully access files on it:
C:\> type \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Users\Eric\Desktop\test.txt
test text 1/2
test text 2/2
When I try to access the same file from java using java.io.File it works fine. However I am unable to convert it to a java.nio.file.Path by calling toPath like this:
File file = newFile(vssPath)
Path path = file.toPath()
Doing so results in an exception trace. This is a known issue for OpenJDK and I get the same result with java 1.8.91:
STACKTRACE:: java.nio.file.InvalidPathException: Illegal character [?] in path at index 2: \\? \GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Users\qa\Desktop\lock_full.txt
at sun.nio.fs.WindowsPathParser.nextSlash(Unknown Source)
at sun.nio.fs.WindowsPathParser.parse(Unknown Source)
at sun.nio.fs.WindowsPathParser.parse(Unknown Source)
at sun.nio.fs.WindowsPath.parse(Unknown Source)
at sun.nio.fs.WindowsFileSystem.getPath(Unknown Source)
at java.io.File.toPath(Unknown Source)
Since I can't get a Path there are certain APIs I'm unable to use, for example java.nio.channels.AsynchronousFileChannel which can only be instantiated with a Path.
Is there any alternative syntax for accessing the shadow copy file that won't run afoul of this JDK limitation? The OpenJDK ticket linked above recommends just omitting the long-UNC prefix (\\?) but I haven't found any variation of this that seems to be legal. For example the following all fail:
C:\> type \\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Users\Eric\Desktop\test.txt
C:\> type \\Device\HarddiskVolumeShadowCopy1\Users\Eric\Desktop\test.txt
C:\> type \\HarddiskVolumeShadowCopy1\Users\Eric\Desktop\test.txt
If there's no variant path I can use to call toPath() then is there some other way I could acquire a java.nio.file.Path that doesn't run afoul of the parser limitation?
In the absence of a timely workaround, my team discussed:
create our own implementation of java.nio.file.Path (or find one in some other library)
change code to avoid the use of java.nio.file.Path
... and we settled on #2. #1 would be a more general workaround should probably be the accepted answer if somebody ever does it and shares.

Related Links

LinkedIn - how to pass query parameter
JAVA Graph/DFS implementation
Guava Cache, how to block access while doing removal
Disable key bindings in eclipse
Java - memory mapped file and flushing
Android : apache HttpComponents Core
Java create URL to arabic filename
Smoothly change position of images
How to make two objects equal to pass assertEquals()?
Create ComboBox within a TitleAreaDialog (JFace dialog)
JComboBox in JTable display invalid data
Vaadin JPAContainer and Tree drag and drop
Jersey with PathParams
How to check how many numbers in array are under 499?
Hash function for sorting words from file
Number of Pivots in Quick Sort

Categories

HOME
arduino-uno
openlayers
pypi
proxy
minimum-spanning-tree
pycharm
react-virtualized
include
hp-exstream
iot
analysis
sharepoint-designer
gps
blueprintjs
communication
handsontable
postgres-xl
timeout
windows-phone-7
hex-editors
caml
dosgi
django-admin
shared-hosting
swingx
custom-wordpress-pages
conemu
errorlevel
ehcache
wijmo
dxf
firebase-crash-reporting
facet
django-storage
dynamic-featured-image
pingfederate
fgetcsv
publish
large-file-upload
atlassian-crucible
google-cloud-nl
procdump
socialengine
functor
titanium-mobile
pdb
scorm2004
catalog
restlet
disassembling
theano.scan
hilbert-curve
azure-ml
total-commander
acoustics
scorm
appcompat
jquery-nestable
sage-one
integrity
setter
snmptrapd
knpmenubundle
bind9
lync-client-sdk
heidisql
lua-5.1
qcustomplot
separator
xna-4.0
wyam
angular-leaflet-directive
vstest.console.exe
web-controls
qcodo
heisenbug
valuechangelistener
dealloc
rtmfp
bundles
meteor-velocity
java.nio.file
spring-io
bulkloader
pushbackinputstream
specification-pattern
distutils
anonymous-methods
browser-detection
bitsharp
tridion-worldserver
ocx
dotnethighcharts
ohm
gwt-ext
php-parser
fluent-interface
perfect-hash
sustainable-pace
pascal-fc
project-hosting
scripting-languages
private-members
multiple-languages

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App