dome icon indicating copy to clipboard operation
dome copied to clipboard

Windows - Dome Fails to load files from other Drives

Open ayuloid opened this issue 2 years ago • 3 comments

Description

By doing anything to load any file (either FileSystem or AudioEngine) from another drive (say, the program is in E: drive and I want stuff from C: drive), or even the same drive (with full path, not relative to main.wren)

Result

A Runtime error as thus:

Runtime error: Could not find file: <filename>

Expected behavior

The File/Music/Image to load

Minimal Reproducible Example

import "io" for FileSystem
import "audio" for AudioEngine

class main {
    construct new() {}
    init() {
		// with FileSystem
        FileSystem.load("C:/files/from_0_to_ONE.txt") // Fails
        FileSystem.load("/C/files/from_0_to_ONE.txt") // Fails
		
		// with AudioEngine
		AudioEngine.load("C:/audio/all_falls_down.mp3") // Fails
		AudioEngine.load("/C/audio/all_falls_down.mp3") // Fails

		// what works is only relative paths
		FileSystem.load("./../../file_on_same_drive.txt") // Works
    }
	update() {}
	draw() {}
}

var Game = main.new()

Specs:

Dome Version: v1.8.0.1 - ffc441e OS: Windows (bear it) 7 Basic Hardware: Lenovo (bear it, again) G460 (2 months older than me)

ayuloid avatar Mar 08 '23 13:03 ayuloid

Interestingly, if you use this path instead: "//./C:/files/from_0_to_ONE.txt", it seems to work just fine. I'm not very familiar with the windows file system, so I don't really have any idea what this actually means.

It seems like the underlying call is just a simple fopen which should be able to open strings in the style of "C:/files/from_0_to_ONE.txt" (I tested this myself). It just doesn't seem to work inside of dome for some reason. There must be something that I overlooked in my admittedly cursory review of the code involved.

catsanddo avatar May 20 '23 15:05 catsanddo

DOME uses this to resolve paths: https://github.com/domeengine/dome/blob/a5c82860f2e9b1f2d457bc106055521d19fb31d1/src/io.c#L84

DOME does expect Unix-style paths, but the MSYS2 runtime should handle that fine. Windows makes it weird.

I am interested in pulling out some of the path handling code and replacing it with this: https://github.com/likle/cwalk

avivbeeri avatar May 20 '23 17:05 avivbeeri

@catsanddo You're right! "//./C:/files/from_0_to_ONE.txt" surprisingly works.

ayuloid avatar May 21 '23 11:05 ayuloid