[Scilab-users] File exist function?

classic Classic list List threaded Threaded
5 messages Options
Claus Futtrup Claus Futtrup
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] File exist function?

Dear Scilabers

I wish to check for the existence of some files. For this I created a simple function:

[out]=function file_exist(fname)
    [fd, err] = mopen(fname); // Try to open file, mode: 'br' (binary-reading)
    if err==0 then
        out=%t;
        mclose(fname);
    else
        out=%f
    end
endfunction

I didn't check, but presumably this would work.

Is such a function already available? Which way is the "official" way to do this in Scilab?

Maybe I'm searching for the wrong word, but I found some ways in Scilab. The "fileinfo" seems to be the closest one to what I wish to do.

Matlab has a function "exist()" which can check for files too. Scilab has the function "exists()" - notice the function name is plural, not singluar - and this one AFAIK only works for Scilab variables (not files), although I didn't check.

If fileinfo is the right way, maybe an example for the help could be to make a file_exist function, to show ... (?) ... when I search for Scilab file exist function, I'm not guided in any specific way/direction and find myself insecure whether I find the right help.

Best regards,
Claus

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Antoine ELIAS-2 Antoine ELIAS-2
Reply | Threaded
Open this post in threaded view
|

Re: File exist function?

Hello Claus,

You can use "isfile" function to check existence if a file and "isdir" for folder.
https://help.scilab.org/docs/6.0.0/en_US/isfile.html
https://help.scilab.org/docs/6.0.0/en_US/isdir.html

Regards,
Antoine
Le 25/01/2018 à 17:43, Claus Futtrup a écrit :
Dear Scilabers

I wish to check for the existence of some files. For this I created a simple function:

[out]=function file_exist(fname)
    [fd, err] = mopen(fname); // Try to open file, mode: 'br' (binary-reading)
    if err==0 then
        out=%t;
        mclose(fname);
    else
        out=%f
    end
endfunction

I didn't check, but presumably this would work.

Is such a function already available? Which way is the "official" way to do this in Scilab?

Maybe I'm searching for the wrong word, but I found some ways in Scilab. The "fileinfo" seems to be the closest one to what I wish to do.

Matlab has a function "exist()" which can check for files too. Scilab has the function "exists()" - notice the function name is plural, not singluar - and this one AFAIK only works for Scilab variables (not files), although I didn't check.

If fileinfo is the right way, maybe an example for the help could be to make a file_exist function, to show ... (?) ... when I search for Scilab file exist function, I'm not guided in any specific way/direction and find myself insecure whether I find the right help.

Best regards,
Claus


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Claus Futtrup Claus Futtrup
Reply | Threaded
Open this post in threaded view
|

Re: File exist function?

Hi Antoine

isfile() looks like exactly what I wish for. I suppose then, this is the correct ("most official") way to do it in Scilab.

Thanks!

Best regards,
Claus

On Thu, Jan 25, 2018 at 7:40 PM, Antoine ELIAS <[hidden email]> wrote:
Hello Claus,

You can use "isfile" function to check existence if a file and "isdir" for folder.
https://help.scilab.org/docs/6.0.0/en_US/isfile.html
https://help.scilab.org/docs/6.0.0/en_US/isdir.html

Regards,
Antoine

Le 25/01/2018 à 17:43, Claus Futtrup a écrit :
Dear Scilabers

I wish to check for the existence of some files. For this I created a simple function:

[out]=function file_exist(fname)
    [fd, err] = mopen(fname); // Try to open file, mode: 'br' (binary-reading)
    if err==0 then
        out=%t;
        mclose(fname);
    else
        out=%f
    end
endfunction

I didn't check, but presumably this would work.

Is such a function already available? Which way is the "official" way to do this in Scilab?

Maybe I'm searching for the wrong word, but I found some ways in Scilab. The "fileinfo" seems to be the closest one to what I wish to do.

Matlab has a function "exist()" which can check for files too. Scilab has the function "exists()" - notice the function name is plural, not singluar - and this one AFAIK only works for Scilab variables (not files), although I didn't check.

If fileinfo is the right way, maybe an example for the help could be to make a file_exist function, to show ... (?) ... when I search for Scilab file exist function, I'm not guided in any specific way/direction and find myself insecure whether I find the right help.

Best regards,
Claus


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users



_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: File exist function?

In reply to this post by Claus Futtrup
Hello Claus,

Le 25/01/2018 à 17:43, Claus Futtrup a écrit :
.../...

Is such a function already available? Which way is the "official" way to do this in Scilab?

Maybe I'm searching for the wrong word, but I found some ways in Scilab. The "fileinfo" seems to be the closest one to what I wish to do.

"isfile" is now added to the See also section of the "fileinfo" page.
At least on the CodeReview.

Looking forward a reviewer and merger
Regards
Samuel


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Claus Futtrup Claus Futtrup
Reply | Threaded
Open this post in threaded view
|

Re: File exist function?

Hi Samuel

Excellent :-) 

Cheers, 
Claus 

On Jan 25, 2018 21:16, "Samuel Gougeon" <[hidden email]> wrote:
Hello Claus,

Le 25/01/2018 à 17:43, Claus Futtrup a écrit :
.../...

Is such a function already available? Which way is the "official" way to do this in Scilab?

Maybe I'm searching for the wrong word, but I found some ways in Scilab. The "fileinfo" seems to be the closest one to what I wish to do.

"isfile" is now added to the See also section of the "fileinfo" page.
At least on the CodeReview.

Looking forward a reviewer and merger
Regards
Samuel


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users