From 5ce44a5e0e2c88c7161942cb59826730bc0e8e5e Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Fri, 21 Jul 2023 02:29:42 +0200 Subject: [PATCH] Move file/directory related methods to Path This moves various methods for copying files and managing directories into the Path type, instead of them being spread across std.fs.dir and std.fs.file as module methods. This results in all path related logic being contained in the Path type. This fixes https://github.com/inko-lang/inko/issues/586 and fixes https://github.com/inko-lang/inko/issues/587. Changelog: changed --- std/src/std/fs/dir.inko | 124 ---------------------- std/src/std/fs/file.inko | 51 --------- std/src/std/fs/path.inko | 169 ++++++++++++++++++++++++++++++ std/test/main.inko | 2 - std/test/std/fs/test_dir.inko | 47 --------- std/test/std/fs/test_file.inko | 60 ++++------- std/test/std/fs/test_path.inko | 101 ++++++++++++++++-- std/test/std/net/test_socket.inko | 8 +- 8 files changed, 284 insertions(+), 278 deletions(-) delete mode 100644 std/src/std/fs/dir.inko delete mode 100644 std/test/std/fs/test_dir.inko diff --git a/std/src/std/fs/dir.inko b/std/src/std/fs/dir.inko deleted file mode 100644 index a466f338a..000000000 --- a/std/src/std/fs/dir.inko +++ /dev/null @@ -1,124 +0,0 @@ -# Manipulating directories on a filesystem. -import std.fs.path.Path -import std.io.Error -import std.string.ToString - -class extern AnyResult { - let @tag: Int - let @value: Any -} - -fn extern inko_directory_create( - process: Pointer[Int8], - path: String, -) -> AnyResult - -fn extern inko_directory_create_recursive( - process: Pointer[Int8], - path: String, -) -> AnyResult - -fn extern inko_directory_remove( - process: Pointer[Int8], - path: String, -) -> AnyResult - -fn extern inko_directory_remove_recursive( - process: Pointer[Int8], - path: String, -) -> AnyResult - -# Creates a new empty directory at the given path. -# -# # Errors -# -# This method returns an `Error` if any of the following conditions are met: -# -# 1. The user lacks the necessary permissions to create the directory. -# 2. The directory already exists. -# -# # Examples -# -# Creating a directory: -# -# import std.fs.dir -# -# dir.create('/tmp/test').unwrap -fn pub create(path: ref ToString) -> Result[Nil, Error] { - match inko_directory_create(_INKO.process, path.to_string) { - case { @tag = 1, @value = _ } -> Result.Ok(nil) - case { @tag = _, @value = e } -> Result.Error(Error.from_os_error(e as Int)) - } -} - -# Creates a new empty directory at the given path, while also creating any -# intermediate directories. -# -# # Errors -# -# This method returns an `Error` if any of the following conditions are met: -# -# 1. The user lacks the necessary permissions to create the directory. -# -# # Examples -# -# Creating a directory: -# -# import std.fs.dir -# -# dir.create_all('/tmp/foo/bar/test').unwrap -fn pub create_all(path: ref ToString) -> Result[Nil, Error] { - match inko_directory_create_recursive(_INKO.process, path.to_string) { - case { @tag = 1, @value = _ } -> Result.Ok(nil) - case { @tag = _, @value = e } -> Result.Error(Error.from_os_error(e as Int)) - } -} - -# Removes the directory at the given path. -# -# # Errors -# -# This method returns an `Error` if any of the following conditions are met: -# -# 1. The user lacks the necessary permissions to remove the directory. -# 2. The directory is not empty. -# 3. The directory does not exist. -# -# # Examples -# -# Removing a directory: -# -# import std.fs.dir -# -# dir.create('/tmp/test').unwrap -# dir.remove('/tmp/test').unwrap -fn pub remove(path: ref ToString) -> Result[Nil, Error] { - match inko_directory_remove(_INKO.process, path.to_string) { - case { @tag = 1, @value = _ } -> Result.Ok(nil) - case { @tag = _, @value = e } -> Result.Error(Error.from_os_error(e as Int)) - } -} - -# Removes the directory and its contents at the given path. -# -# # Errors -# -# This method returns an `Error` if any of the following conditions are met: -# -# 1. The user lacks the necessary permissions to remove the directory. -# 2. The directory does not exist. -# -# # Examples -# -# Removing a directory: -# -# import std.fs.dir -# -# dir.create_all('/tmp/foo/bar').unwrap -# dir.remove_all('/tmp/foo').unwrap -fn pub remove_all(path: ref ToString) -> Result[Nil, Error] { - match inko_directory_remove_recursive(_INKO.process, path.to_string) { - case { @tag = 1, @value = _ } -> Result.Ok(nil) - case { @tag = _, @value = e } -> Result.Error(Error.from_os_error(e as Int)) - } -} diff --git a/std/src/std/fs/file.inko b/std/src/std/fs/file.inko index a3dacab73..34c2386da 100644 --- a/std/src/std/fs/file.inko +++ b/std/src/std/fs/file.inko @@ -14,7 +14,6 @@ import std.drop.Drop import std.fs.path.(IntoPath, Path) import std.io.(Error, Read, Seek, Size, Write) -import std.string.ToString let FILE_READ_ONLY = 0 let FILE_WRITE_ONLY = 1 @@ -43,12 +42,6 @@ fn extern inko_file_flush( ) -> AnyResult fn extern inko_file_drop(file: Pointer[Int8]) -fn extern inko_file_copy( - state: Pointer[Int8], - process: Pointer[Int8], - from: String, - to: String, -) -> AnyResult fn extern inko_file_open( process: Pointer[Int8], @@ -64,7 +57,6 @@ fn extern inko_file_read( size: Int, ) -> IntResult -fn extern inko_file_remove(process: Pointer[Int8], path: String) -> AnyResult fn extern inko_file_seek( state: Pointer[Int8], process: Pointer[Int8], @@ -92,49 +84,6 @@ fn extern inko_file_write_string( input: String, ) -> IntResult -# Removes the file for the given file path. -# -# # Examples -# -# Removing a file: -# -# import std.fs.file.(self, WriteOnlyFile) -# -# let handle = WriteOnlyFile.new('/tmp/test.txt').unwrap -# -# handle.write('hello').unwrap -# file.remove('/tmp/test.txt').unwrap -fn pub remove(path: ref ToString) -> Result[Nil, Error] { - match inko_file_remove(_INKO.process, path.to_string) { - case { @tag = 1, @value = _ } -> Result.Ok(nil) - case { @tag = _, @value = e } -> Result.Error(Error.from_os_error(e as Int)) - } -} - -# Copies a file from the source destination to the target destination, -# returning the number of copied bytes. -# -# # Examples -# -# Copying a file: -# -# import std.fs.file.(self, WriteOnlyFile) -# -# let handle = WriteOnlyFile.new('/tmp/test.txt').unwrap -# -# handle.write('hello').unwrap -# file.copy(from: '/tmp/test.txt', to: '/tmp/test2.txt').unwrap -fn pub copy(from: ref ToString, to: ref ToString) -> Result[Int, Error] { - match inko_file_copy( - _INKO.state, _INKO.process, from.to_string, to.to_string - ) { - case { @tag = 0, @value = v } -> Result.Ok(v as Int) - case { @tag = _, @value = e } -> Result.Error( - Error.from_os_error(e as Int) - ) - } -} - # A file that can only be used for reads. class pub ReadOnlyFile { # The path of the file. diff --git a/std/src/std/fs/path.inko b/std/src/std/fs/path.inko index f443b3e77..e1a13d9b5 100644 --- a/std/src/std/fs/path.inko +++ b/std/src/std/fs/path.inko @@ -20,6 +20,35 @@ class extern AnyResult { let @value: Any } +fn extern inko_file_remove(process: Pointer[Int8], path: String) -> AnyResult + +fn extern inko_file_copy( + state: Pointer[Int8], + process: Pointer[Int8], + from: String, + to: String, +) -> AnyResult + +fn extern inko_directory_remove( + process: Pointer[Int8], + path: String, +) -> AnyResult + +fn extern inko_directory_create( + process: Pointer[Int8], + path: String, +) -> AnyResult + +fn extern inko_directory_create_recursive( + process: Pointer[Int8], + path: String, +) -> AnyResult + +fn extern inko_directory_remove_recursive( + process: Pointer[Int8], + path: String, +) -> AnyResult + fn extern inko_file_size( state: Pointer[Int8], process: Pointer[Int8], @@ -406,6 +435,146 @@ class pub Path { ReadDirectory { @path = @path, @inner = inner } } } + + # Removes the file `self` points to. + # + # If `self` points to a directory, an error is returned. + # + # # Examples + # + # import std.fs.file.WriteOnlyFile + # import std.fs.path.Path + # + # let path = Path.new('/tmp/test.txt') + # let handle = WriteOnlyFile.new(path).unwrap + # + # handle.write_string('hello').unwrap + # path.remove_file.unwrap + fn pub remove_file -> Result[Nil, Error] { + match inko_file_remove(_INKO.process, @path) { + case { @tag = 1, @value = _ } -> Result.Ok(nil) + case { @tag = _, @value = e } -> Result.Error( + Error.from_os_error(e as Int) + ) + } + } + + # Removes the directory `self` points to. + # + # If `self` points to a file, an error is returned. + # + # # Examples + # + # import std.fs.path.Path + # + # let path = Path.new('/tmp/foo') + # + # path.create_directory.unwrap + # path.remove_directory.unwrap + fn pub remove_directory -> Result[Nil, Error] { + match inko_directory_remove(_INKO.process, @path) { + case { @tag = 1, @value = _ } -> Result.Ok(nil) + case { @tag = _, @value = e } -> Result.Error( + Error.from_os_error(e as Int) + ) + } + } + + # Removes the directory and its contents `self` points to. + # + # # Errors + # + # This method returns an `Error` if any of the following conditions are met: + # + # 1. The user lacks the necessary permissions to remove the directory. + # 2. The directory does not exist. + # + # # Examples + # + # Removing a directory: + # + # import std.fs.path.Path + # + # Path.new('/tmp/foo/bar').create_directory_all.unwrap + # Path.new('/tmp/foo').remove_directory_all.unwrap + fn pub remove_directory_all -> Result[Nil, Error] { + match inko_directory_remove_recursive(_INKO.process, @path) { + case { @tag = 1, @value = _ } -> Result.Ok(nil) + case { @tag = _, @value = e } -> Result.Error( + Error.from_os_error(e as Int) + ) + } + } + + # Creates a new empty directory at the path `self` points to. + # + # # Errors + # + # This method returns an `Error` if any of the following conditions are met: + # + # 1. The user lacks the necessary permissions to create the directory. + # 2. The directory already exists. + # + # # Examples + # + # import std.fs.path.Path + # + # Path.new('/tmp/test').create_directory.unwrap + fn pub create_directory -> Result[Nil, Error] { + match inko_directory_create(_INKO.process, @path) { + case { @tag = 1, @value = _ } -> Result.Ok(nil) + case { @tag = _, @value = e } -> Result.Error( + Error.from_os_error(e as Int) + ) + } + } + + # Creates a new empty directory at the path `self` points to, while also + # creating any intermediate directories. + # + # # Errors + # + # This method returns an `Error` if any of the following conditions are met: + # + # 1. The user lacks the necessary permissions to create the directory. + # + # # Examples + # + # import std.fs.path.Path + # + # Path.new('/tmp/foo/bar/test').create_directory_all.unwrap + fn pub create_directory_all -> Result[Nil, Error] { + match inko_directory_create_recursive(_INKO.process, @path) { + case { @tag = 1, @value = _ } -> Result.Ok(nil) + case { @tag = _, @value = e } -> Result.Error( + Error.from_os_error(e as Int) + ) + } + } + + # Copies the file `self` points to the file `to` points to, returning the + # number of copied bytes. + # + # If `self` or `to` points to a directory, an error is returned. + # + # # Examples + # + # import std.fs.file.WriteOnlyFile + # import std.fs.path.Path + # + # let path = Path.new('/tmp/test.txt') + # let file = WriteOnlyFile.new(path).unwrap + # + # file.write_string('hello').unwrap + # path.copy(to: '/tmp/test2.txt').unwrap + fn pub copy(to: ref ToString) -> Result[Int, Error] { + match inko_file_copy(_INKO.state, _INKO.process, @path, to.to_string) { + case { @tag = 0, @value = v } -> Result.Ok(v as Int) + case { @tag = _, @value = e } -> Result.Error( + Error.from_os_error(e as Int) + ) + } + } } # A type from which a new `Path` can be created. diff --git a/std/test/main.inko b/std/test/main.inko index 38415612b..1405468b5 100644 --- a/std/test/main.inko +++ b/std/test/main.inko @@ -12,7 +12,6 @@ import std.crypto.test_sha1 import std.crypto.test_sha2 import std.endian.test_big import std.endian.test_little -import std.fs.test_dir import std.fs.test_file import std.fs.test_path import std.hash.test_siphash @@ -60,7 +59,6 @@ class async Main { test_channel.tests(tests) test_cmp.tests(tests) test_debug.tests(tests) - test_dir.tests(tests) test_drop.tests(tests) test_env.tests(tests) test_file.tests(tests) diff --git a/std/test/std/fs/test_dir.inko b/std/test/std/fs/test_dir.inko deleted file mode 100644 index 549a859e6..000000000 --- a/std/test/std/fs/test_dir.inko +++ /dev/null @@ -1,47 +0,0 @@ -import std.env -import std.fs.dir -import std.test.Tests - -fn pub tests(t: mut Tests) { - t.test('dir.create') fn (t) { - let path = env.temporary_directory.join("inko-test-dir-{t.id}") - - t.true(dir.create(path).ok?) - t.true(path.directory?) - t.true(dir.create(path).error?) - - dir.remove(path).unwrap - } - - t.test('dir.create_all') fn (t) { - let root = env.temporary_directory.join("inko-test-dir-{t.id}") - let path = root.join('foo').join('bar') - - t.true(dir.create_all(path).ok?) - t.true(path.directory?) - t.true(dir.create_all(path).ok?) - - dir.remove_all(root).unwrap - } - - t.test('dir.remove') fn (t) { - let path = env.temporary_directory.join("inko-test-dir-{t.id}") - - dir.create(path).unwrap - - t.true(dir.remove(path).ok?) - t.true(dir.remove(path).error?) - t.false(path.directory?) - } - - t.test('dir.remove_all') fn (t) { - let root = env.temporary_directory.join("inko-test-dir-{t.id}") - let path = root.join('foo').join('bar') - - dir.create_all(path).unwrap - - t.true(dir.remove_all(root).ok?) - t.true(dir.remove_all(root).error?) - t.false(root.directory?) - } -} diff --git a/std/test/std/fs/test_file.inko b/std/test/std/fs/test_file.inko index fb2913820..adf6f627b 100644 --- a/std/test/std/fs/test_file.inko +++ b/std/test/std/fs/test_file.inko @@ -19,30 +19,6 @@ fn read(from: ref Path) -> String { } fn pub tests(t: mut Tests) { - t.test('file.remove') fn (t) { - let path = env.temporary_directory.join("inko-test-{t.id}") - - t.true(file.remove(path).error?) - - write('test', to: path) - - t.true(file.remove(path).ok?) - t.false(path.exists?) - } - - t.test('file.copy') fn (t) { - let path1 = env.temporary_directory.join("inko-test-{t.id}-1") - let path2 = env.temporary_directory.join("inko-test-{t.id}-2") - - write('test', to: path1) - - t.true(file.copy(from: path1, to: path2).ok?) - t.equal(read(path2), 'test') - - file.remove(path1).unwrap - file.remove(path2).unwrap - } - t.test('ReadOnlyFile.new') fn (t) { let path = env.temporary_directory.join("inko-test-{t.id}") @@ -52,7 +28,7 @@ fn pub tests(t: mut Tests) { t.true(ReadOnlyFile.new(path.clone).ok?) - file.remove(path).unwrap + path.remove_file.unwrap } t.test('ReadOnlyFile.read') fn (t) { @@ -67,7 +43,7 @@ fn pub tests(t: mut Tests) { t.equal(bytes.into_string, 'test') - file.remove(path).unwrap + path.remove_file.unwrap } t.test('ReadOnlyFile.seek') fn (t) { @@ -83,7 +59,7 @@ fn pub tests(t: mut Tests) { t.equal(bytes.into_string, 'est') - file.remove(path).unwrap + path.remove_file.unwrap } t.test('ReadOnlyFile.size') fn (t) { @@ -95,7 +71,7 @@ fn pub tests(t: mut Tests) { t.true(handle.size.unwrap >= 0) - file.remove(path).unwrap + path.remove_file.unwrap } t.test('WriteOnlyFile.new') fn (t) { @@ -104,7 +80,7 @@ fn pub tests(t: mut Tests) { t.true(WriteOnlyFile.new(path.clone).ok?) t.true(WriteOnlyFile.new(path.clone).ok?) - file.remove(path).unwrap + path.remove_file.unwrap } t.test('WriteOnlyFile.append') fn (t) { @@ -113,7 +89,7 @@ fn pub tests(t: mut Tests) { t.true(WriteOnlyFile.append(path.clone).ok?) t.true(WriteOnlyFile.append(path.clone).ok?) - file.remove(path).unwrap + path.remove_file.unwrap } t.test('WriteOnlyFile.write_bytes') fn (t) { @@ -133,7 +109,7 @@ fn pub tests(t: mut Tests) { t.equal(read(path), 'testing') - file.remove(path).unwrap + path.remove_file.unwrap } t.test('WriteOnlyFile.write_string') fn (t) { @@ -153,7 +129,7 @@ fn pub tests(t: mut Tests) { t.equal(read(path), 'testing') - file.remove(path).unwrap + path.remove_file.unwrap } t.test('WriteOnlyFile.flush') fn (t) { @@ -165,7 +141,7 @@ fn pub tests(t: mut Tests) { t.equal(read(path), 'test') - file.remove(path).unwrap + path.remove_file.unwrap } t.test('WriteOnlyFile.seek') fn (t) { @@ -178,7 +154,7 @@ fn pub tests(t: mut Tests) { t.equal(read(path), 'ting') - file.remove(path).unwrap + path.remove_file.unwrap } t.test('ReadWriteFile.new') fn (t) { @@ -187,7 +163,7 @@ fn pub tests(t: mut Tests) { t.true(ReadWriteFile.new(path.clone).ok?) t.true(ReadWriteFile.new(path.clone).ok?) - file.remove(path).unwrap + path.remove_file.unwrap } t.test('ReadWriteFile.append') fn (t) { @@ -196,7 +172,7 @@ fn pub tests(t: mut Tests) { t.true(ReadWriteFile.append(path.clone).ok?) t.true(ReadWriteFile.append(path.clone).ok?) - file.remove(path).unwrap + path.remove_file.unwrap } t.test('ReadWriteFile.read') fn (t) { @@ -211,7 +187,7 @@ fn pub tests(t: mut Tests) { t.equal(bytes.to_string, 'test') - file.remove(path).unwrap + path.remove_file.unwrap } t.test('ReadWriteFile.write_bytes') fn (t) { @@ -231,7 +207,7 @@ fn pub tests(t: mut Tests) { t.equal(read(path), 'testing') - file.remove(path).unwrap + path.remove_file.unwrap } t.test('ReadWriteFile.write_string') fn (t) { @@ -251,7 +227,7 @@ fn pub tests(t: mut Tests) { t.equal(read(path), 'testing') - file.remove(path).unwrap + path.remove_file.unwrap } t.test('ReadWriteFile.flush') fn (t) { @@ -263,7 +239,7 @@ fn pub tests(t: mut Tests) { t.equal(read(path), 'test') - file.remove(path).unwrap + path.remove_file.unwrap } t.test('ReadWriteFile.seek') fn (t) { @@ -276,7 +252,7 @@ fn pub tests(t: mut Tests) { t.equal(read(path), 'ting') - file.remove(path).unwrap + path.remove_file.unwrap } t.test('ReadWriteFile.size') fn (t) { @@ -288,6 +264,6 @@ fn pub tests(t: mut Tests) { t.true(handle.size.unwrap >= 0) - file.remove(path).unwrap + path.remove_file.unwrap } } diff --git a/std/test/std/fs/test_path.inko b/std/test/std/fs/test_path.inko index 5cd4ee612..7f69d8e66 100644 --- a/std/test/std/fs/test_path.inko +++ b/std/test/std/fs/test_path.inko @@ -1,8 +1,7 @@ import helpers.(fmt) import std.env import std.fs.(DirectoryEntry, FileType) -import std.fs.dir -import std.fs.file.(self, WriteOnlyFile) +import std.fs.file.(self, ReadOnlyFile, WriteOnlyFile) import std.fs.path.(self, Path) import std.sys import std.test.Tests @@ -19,6 +18,15 @@ fn accessed_at? -> Bool { env.temporary_directory.accessed_at.ok? } +fn read(from: ref Path) -> String { + let file = ReadOnlyFile.new(from.clone).unwrap + let bytes = ByteArray.new + + file.read_all(bytes).unwrap + + bytes.into_string +} + fn write(string: String, to: ref Path) { let file = WriteOnlyFile.new(to.clone).unwrap @@ -37,7 +45,7 @@ fn pub tests(t: mut Tests) { write('test', to: path) t.true(path.file?) - file.remove(path).unwrap + path.remove_file.unwrap } t.test('Path.directory?') fn (t) { @@ -131,12 +139,12 @@ fn pub tests(t: mut Tests) { let temp = env.temporary_directory let bar = temp.join('foo').join('bar') - dir.create_all(bar).unwrap + bar.create_directory_all.unwrap let expanded = bar.join('..').join('..').expand t.equal(expanded, Result.Ok(temp)) - dir.remove_all(bar) + bar.remove_directory_all } t.test('Path.tail') fn (t) { @@ -151,8 +159,8 @@ fn pub tests(t: mut Tests) { let root = env.temporary_directory.join("inko-test-dir-{t.id}") let foo = root.join('foo') - dir.create(root).unwrap - dir.create(foo).unwrap + root.create_directory.unwrap + foo.create_directory.unwrap let entry = root .list @@ -165,7 +173,7 @@ fn pub tests(t: mut Tests) { Option.Some(DirectoryEntry { @path = foo, @type = FileType.Directory }) ) - let _ = dir.remove_all(root) + let _ = root.remove_directory_all } t.test('Path.list with an invalid directory') fn (t) { @@ -173,4 +181,81 @@ fn pub tests(t: mut Tests) { t.true(root.list.error?) } + + t.test('Path.remove_file') fn (t) { + let path = env.temporary_directory.join("inko-test-{t.id}") + + t.true(path.remove_file.error?) + + write('test', to: path) + + t.true(path.remove_file.ok?) + t.false(path.exists?) + } + + t.test('Path.remove_directory') fn (t) { + let path = env.temporary_directory.join("inko-test-dir-{t.id}") + + t.true(path.remove_directory.error?) + + path.create_directory.unwrap + + t.true(path.remove_directory.ok?) + t.false(path.directory?) + } + + t.test('Path.create_directory') fn (t) { + let path = env.temporary_directory.join("inko-test-dir-{t.id}") + + t.true(path.create_directory.ok?) + t.true(path.directory?) + t.true(path.create_directory.error?) + + path.remove_directory.unwrap + } + + t.test('Path.create_directory_all') fn (t) { + let root = env.temporary_directory.join("inko-test-dir-{t.id}") + let path = root.join('foo').join('bar') + + t.true(path.create_directory_all.ok?) + t.true(path.directory?) + t.true(path.create_directory_all.ok?) + + root.remove_directory_all.unwrap + } + + t.test('Path.remove_directory') fn (t) { + let path = env.temporary_directory.join("inko-test-dir-{t.id}") + + path.create_directory.unwrap + + t.true(path.remove_directory.ok?) + t.true(path.remove_directory.error?) + t.false(path.directory?) + } + + t.test('Path.remove_directory_all') fn (t) { + let root = env.temporary_directory.join("inko-test-dir-{t.id}") + let path = root.join('foo').join('bar') + + path.create_directory_all.unwrap + + t.true(root.remove_directory_all.ok?) + t.true(root.remove_directory_all.error?) + t.false(root.directory?) + } + + t.test('Path.copy') fn (t) { + let path1 = env.temporary_directory.join("inko-test-{t.id}-1") + let path2 = env.temporary_directory.join("inko-test-{t.id}-2") + + write('test', to: path1) + + t.true(path1.copy(to: path2).ok?) + t.equal(read(path2), 'test') + + path1.remove_file.unwrap + path2.remove_file.unwrap + } } diff --git a/std/test/std/net/test_socket.inko b/std/test/std/net/test_socket.inko index 92c85d7af..49f5bd296 100644 --- a/std/test/std/net/test_socket.inko +++ b/std/test/std/net/test_socket.inko @@ -19,15 +19,15 @@ class SocketPath { fn static pair(id: Int) -> (SocketPath, SocketPath) { let p1 = env.temporary_directory.join("inko-test-{id}-1.sock") let p2 = env.temporary_directory.join("inko-test-{id}-2.sock") - let _ = file.remove(p1) - let _ = file.remove(p2) + let _ = p1.remove_file + let _ = p2.remove_file (SocketPath { @path = p1 }, SocketPath { @path = p2 }) } fn static new(id: Int) -> SocketPath { let path = env.temporary_directory.join("inko-test-{id}.sock") - let _ = file.remove(path) + let _ = path.remove_file SocketPath { @path = path } } @@ -41,7 +41,7 @@ impl ToString for SocketPath { impl Drop for SocketPath { fn mut drop { - let _ = file.remove(@path) + let _ = @path.remove_file } }