93
94 if (Files.isWritable(path)) {
95 throw new RuntimeException("Test file " + path + " is writable");
96 }
97
98 FileTime creationTime =
99 (FileTime)Files.getAttribute(path, "basic:creationTime");
100 System.out.format("%s creation time: %s%n", path, creationTime);
101
102 long size = Files.size(path);
103 int capacity = (int)Math.min(1024, size);
104 ByteBuffer buf = ByteBuffer.allocate(capacity);
105 try (SeekableByteChannel sbc = Files.newByteChannel(path)) {
106 int n = sbc.read(buf);
107 System.out.format("Read %d bytes from %s%n", n, path);
108 }
109 }
110
111 private static final void checkDataVolume() throws IOException {
112 System.out.format("--- Checking data volume %s ---%n", DATA_VOLUME);
113 Path data = Paths.get(DATA_VOLUME, "tmp");
114 if (Files.getFileStore(data).isReadOnly()) {
115 throw new RuntimeException("Data volume is read-only");
116 }
117
118 Path tempDir = Files.createTempDirectory(data, "tempDir");
119 tempDir.toFile().deleteOnExit();
120 System.out.format("Temporary directory: %s%n", tempDir);
121 if (!Files.isWritable(tempDir)) {
122 throw new RuntimeException("Temporary directory is not writable");
123 }
124
125 Path tempFile = Files.createTempFile(tempDir, "tempFile", null);
126 tempFile.toFile().deleteOnExit();
127 System.out.format("Temporary file: %s%n", tempFile);
128 if (!Files.isWritable(tempFile)) {
129 throw new RuntimeException("Temporary file is not writable");
130 }
131
132 byte[] bytes = new byte[42];
133 new Random().nextBytes(bytes);
|
93
94 if (Files.isWritable(path)) {
95 throw new RuntimeException("Test file " + path + " is writable");
96 }
97
98 FileTime creationTime =
99 (FileTime)Files.getAttribute(path, "basic:creationTime");
100 System.out.format("%s creation time: %s%n", path, creationTime);
101
102 long size = Files.size(path);
103 int capacity = (int)Math.min(1024, size);
104 ByteBuffer buf = ByteBuffer.allocate(capacity);
105 try (SeekableByteChannel sbc = Files.newByteChannel(path)) {
106 int n = sbc.read(buf);
107 System.out.format("Read %d bytes from %s%n", n, path);
108 }
109 }
110
111 private static final void checkDataVolume() throws IOException {
112 System.out.format("--- Checking data volume %s ---%n", DATA_VOLUME);
113 Path data = Paths.get(DATA_VOLUME, "private", "tmp");
114 if (Files.getFileStore(data).isReadOnly()) {
115 throw new RuntimeException("Data volume is read-only");
116 }
117
118 Path tempDir = Files.createTempDirectory(data, "tempDir");
119 tempDir.toFile().deleteOnExit();
120 System.out.format("Temporary directory: %s%n", tempDir);
121 if (!Files.isWritable(tempDir)) {
122 throw new RuntimeException("Temporary directory is not writable");
123 }
124
125 Path tempFile = Files.createTempFile(tempDir, "tempFile", null);
126 tempFile.toFile().deleteOnExit();
127 System.out.format("Temporary file: %s%n", tempFile);
128 if (!Files.isWritable(tempFile)) {
129 throw new RuntimeException("Temporary file is not writable");
130 }
131
132 byte[] bytes = new byte[42];
133 new Random().nextBytes(bytes);
|