Why filelib:is_dir and filelib:is_regular functions doesn't work properly with files and folder that contain blank space?

Viewed 46

I have the directory C:/Users/David/test

This directory contains:

-test one (folder)
-test.one (folder)
-Nuevo documento de texto.txt (file)
-module(tut).
-export([main/0]).

main() -> 
 {_, DD} = file:list_dir("C:/Users/David/test"),
 [{H, filelib:is_dir(H)} || H <-DD].

When I run the code the two folders give me false. And they should return true.

When I change is_dir by is_regular and execute the code all three are false too, but Nuevo documento de texto.txt is a regular file.

1 Answers

You need to provide the full path for the filelib:is_dir to work correctly.

[{H,filelib:is_dir("C:/Users/David/test/" ++ H)}|| H <-DD].
Related