HaxeFoundation / HaxeFoundation/haxe
Can't move (rename) files across filesystems (e.g. encrypted home to /tmp/) in Linux & Mac, both Neko & cpp
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
Alright, another crazy issue that's probably my own fault somehow. Using cpp or neko targets, `sys.FileSystem.rename` can't move a file to `/tmp/` on my linux machine (can't test Mac just now...) `sys.io.File.saveContents` can write a file in `/tmp/` and rename can move a file to other locations (e.g. home folder.)
Here's a test:
```
class Main {
static function main() {
var env = Sys.environment();
var home = env.get("HOME");
var fn = home+"/test.bin";
// Clean files
function clean() {
if (sys.FileSystem.exists(fn)) sys.FileSystem.deleteFile(fn);
if (sys.FileSystem.exists(fn+".2")) sys.FileSystem.deleteFile(fn+".2");
if (sys.FileSystem.exists("/tmp/move.bin")) sys.FileSystem.deleteFile("/tmp/move.bin");
if (sys.FileSystem.exists("/tmp/write.bin")) sys.FileSystem.deleteFile("/tmp/write.bin");
}
clean();
trace("Create file: "+fn);
sys.io.File.saveContent(fn, "A test file\n");
if (sys.FileSystem.exists(fn)) trace("Success!"); else trace("FAIL!");
trace("Move to home folder, works?");
sys.FileSystem.rename(fn, fn+".2");
if (sys.FileSystem.exists(fn+".2")) trace("Success!"); else trace("FAIL!");
trace("Move to /tmp folder, fails...");
try { sys.FileSystem.rename(fn+".2", "/tmp/move.bin"); } catch (e:Dynamic) { }
if (sys.FileSystem.exists("/tmp/move.bin")) trace("Success!"); else trace("FAIL!");
trace("Write file directly to /tmp/write.bin...");
sys.io.File.saveContent("/tmp/write.bin", "A test file\n");
if (sys.FileSystem.exists("/tmp/write.bin")) trace("Success!"); else trace("FAIL!");
}
}
```
And the output on my machine:
```
Main.hx:21: Create file: /home/jward/test.bin
Main.hx:23: Success!
Main.hx:25: Move to home folder, works?
Main.hx:27: Success!
Main.hx:29: Move to /tmp folder, fails...
Main.hx:31: FAIL!
Main.hx:33: Write file directly to /tmp/write.bin...
Main.hx:35: Success!
```
FYI: this doesn't apply to Windows, there is no `/tmp/`
1) Can someone test this on Mac?
2) Can someone verify this on Linux?
3) Can someone spot my mistake? =D
Contributor guide
Assessment
This issue has not been assessed yet.