Adding new_from_path.

This commit is contained in:
sergiotarxz 2022-07-09 11:03:53 +02:00
parent 854ba7fae4
commit 0d90b26603
2 changed files with 16 additions and 0 deletions

View File

@ -15,10 +15,18 @@ namespace Owl {
return final_string;
}
public static Owl.Path cwd () {
return new Owl.Path (GLib.File.new_for_path ("."));
}
public Path (GLib.File file) {
this.file = file;
}
public Path.from_path (string path) {
this.file = GLib.File.new_for_path (path);
}
public Path.tempdir () throws GLib.Error {
this.is_tmp = true;
var file = GLib.File.new_for_path(GLib.Environment.get_tmp_dir () + Config.WS + get_random_string ());

View File

@ -102,6 +102,14 @@ int main (string[] args) {
GLib.Test.fail_printf ("%s\n", error.message);
}
});
GLib.Test.add_func ("/test/owl/path-cwd", () => {
try {
var cwd = Owl.Path.cwd ();
assert (cwd.child("src").exists ());
} catch (GLib.Error error) {
GLib.Test.fail_printf ("%s\n", error.message);
}
});
return GLib.Test.run ();
}