equal
deleted
inserted
replaced
241 write_xz(path.file, text, options) |
241 write_xz(path.file, text, options) |
242 def write_xz(path: Path, text: CharSequence): Unit = write_xz(path, text, XZ.options()) |
242 def write_xz(path: Path, text: CharSequence): Unit = write_xz(path, text, XZ.options()) |
243 |
243 |
244 def write_backup(path: Path, text: CharSequence) |
244 def write_backup(path: Path, text: CharSequence) |
245 { |
245 { |
246 path.file renameTo path.backup.file |
246 mv(path, path.backup) |
247 write(path, text) |
247 write(path, text) |
248 } |
248 } |
249 |
249 |
250 def write_backup2(path: Path, text: CharSequence) |
250 def write_backup2(path: Path, text: CharSequence) |
251 { |
251 { |
252 path.file renameTo path.backup2.file |
252 mv(path, path.backup2) |
253 write(path, text) |
253 write(path, text) |
254 } |
254 } |
255 |
255 |
256 |
256 |
257 /* append */ |
257 /* append */ |
261 StandardOpenOption.APPEND, StandardOpenOption.CREATE) |
261 StandardOpenOption.APPEND, StandardOpenOption.CREATE) |
262 |
262 |
263 def append(path: Path, text: CharSequence): Unit = append(path.file, text) |
263 def append(path: Path, text: CharSequence): Unit = append(path.file, text) |
264 |
264 |
265 |
265 |
266 /* copy */ |
266 /* eq */ |
267 |
267 |
268 def eq(file1: JFile, file2: JFile): Boolean = |
268 def eq(file1: JFile, file2: JFile): Boolean = |
269 try { java.nio.file.Files.isSameFile(file1.toPath, file2.toPath) } |
269 try { java.nio.file.Files.isSameFile(file1.toPath, file2.toPath) } |
270 catch { case ERROR(_) => false } |
270 catch { case ERROR(_) => false } |
|
271 |
|
272 def eq(path1: Path, path2: Path): Boolean = eq(path1.file, path2.file) |
|
273 |
|
274 |
|
275 /* copy */ |
271 |
276 |
272 def copy(src: JFile, dst: JFile) |
277 def copy(src: JFile, dst: JFile) |
273 { |
278 { |
274 val target = if (dst.isDirectory) new JFile(dst, src.getName) else dst |
279 val target = if (dst.isDirectory) new JFile(dst, src.getName) else dst |
275 if (!eq(src, target)) |
280 if (!eq(src, target)) |
277 StandardCopyOption.COPY_ATTRIBUTES, |
282 StandardCopyOption.COPY_ATTRIBUTES, |
278 StandardCopyOption.REPLACE_EXISTING) |
283 StandardCopyOption.REPLACE_EXISTING) |
279 } |
284 } |
280 |
285 |
281 def copy(path1: Path, path2: Path): Unit = copy(path1.file, path2.file) |
286 def copy(path1: Path, path2: Path): Unit = copy(path1.file, path2.file) |
|
287 |
|
288 |
|
289 /* move */ |
|
290 |
|
291 def mv(file1: JFile, file2: JFile): Unit = |
|
292 Files.move(file1.toPath, file2.toPath, StandardCopyOption.REPLACE_EXISTING) |
|
293 |
|
294 def mv(path1: Path, path2: Path): Unit = mv(path1.file, path2.file) |
282 } |
295 } |