c-smile / sciter-sdk

Sciter is an embeddable HTML/CSS/scripting engine
http://sciter.com
Other
2.11k stars 224 forks source link

Stream.openFile could not find file on windows #107

Closed woodgear closed 5 years ago

woodgear commented 5 years ago

sciter dll version: 4.2.6.10 (32) sciter binding : sciter-rs = "0.5.44" windows version :win10 64

extern crate sciter;
fn main() {
    let mut frame = sciter::WindowBuilder::main_window().create();
    frame.load_file(r#"C:\Users\developer\Desktop\test_sciter_file\main.html"#);
    frame.run_app();
}
<html>
    <head>
        <title>Test</title>
        <script type="text/tiscript">
        function getData(path) {
            var config = Stream.openFile(path);
            if(config)
            {
                // Load the contents of the file into a json object 
                var jsonData = parseData(config);

                if(jsonData){
                stdout.printf("JSON data is : %v\n", jsonData);
                }
                else{
                stdout.println("No data");
                }
                config.close();
            }else {
                stdout.println("could not find file ",path);                
            }
        }
        getData("config.json");
        getData(self.url("config.json"));
        getData("C:\\Users\\developer\\Desktop\\test_sciter_file\\config.json");
        getData("C:/Users/developer/Desktop/test_sciter_file/config.json");            
        getData(".\\config.json");
        getData(self.url(".\\config.json"));
        getData(self.url("config.json"));
        getData(self.url("test_sciter_file\\config.json"));
    </script>
    </head>
    <body>
        <button #t>TEST</button>
    </body>
</html>

output is

INFO:TIS: could not find file  config.json
INFO:TIS: could not find file  file://C:/Users/developer/Desktop/test_sciter_file/config.json
INFO:TIS: could not find file  C:\Users\developer\Desktop\test_sciter_file\config.json
INFO:TIS: could not find file  C:/Users/developer/Desktop/test_sciter_file/config.json
INFO:TIS: could not find file  .\config.json
INFO:TIS: could not find file  file://C:/Users/developer/Desktop/test_sciter_file/config.json
INFO:TIS: could not find file  file://C:/Users/developer/Desktop/test_sciter_file/config.json
INFO:TIS: could not find file  file://C:/Users/developer/Desktop/test_sciter_file/test_sciter_file/config.json

file struct is

    Directory: C:\Users\developer\Desktop\test_sciter_file

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        3/11/2019   5:52 PM                src
d-----        3/11/2019   5:54 PM                target
-a----        3/11/2019   5:52 PM             19 .gitignore
-a----        3/11/2019   5:54 PM           3125 Cargo.lock
-a----        3/11/2019   5:54 PM            154 Cargo.toml
-a----        3/11/2019   6:03 PM            110 config.json
-a----        3/11/2019   6:13 PM           1231 main.html
-a----        2/20/2019   6:35 AM        5328376 sciter.dll
-a----        3/11/2019   6:10 PM             77 test.cmd
-a----        3/11/2019   6:17 PM         269824 test_sciter_file.exe

i am confuse what happen now,please give some advise

pravic commented 5 years ago

Isn't this related to the "4.2.5.0" breaking change?

woodgear commented 5 years ago

T_T it seems so (almost waste me a whole day) . I think we should add those kinds of tip into tiscript api document.if you could tell me how to update that, i will be pleasured to do.

pravic commented 5 years ago

One of https://github.com/sciter-sdk/rust-sciter/pull/47/files or https://github.com/sciter-sdk/rust-sciter/blob/master/examples/interop.rs#L136