[erlang-questions] file:list_dir/1 mystery -- a clue

lloyd <>
Tue Dec 6 20:03:59 CET 2016


Ah, my eyes did miss something:

code:priv_dir returns the Erlang directory.

1> Priv = code:priv_dir(erlguten).
"/home/lloyd/Erlang/erlguten/priv"

But that still puzzles me. Where should I put my images?

Thanks again,

LRP



Hello,

Working with a fork of erlguten, I created an image directory under priv today but file:list_dir/1 can't find it.

Bash sees it:

Test 1:

:~/EG/erlguten/priv$ ls -l
total 20
-rw-rw-r-- 1 lloyd lloyd  179 Nov  1 16:45 font_locations
drwxrwxr-x 5 lloyd lloyd 4096 Nov  1 16:45 fonts
drwxrwxr-x 3 lloyd lloyd 4096 Nov  1 16:45 hyphenation
drwxrwxr-x 2 lloyd lloyd 4096 Dec  3 14:12 images
drwxrwxr-x 2 lloyd lloyd 4096 Nov  1 16:45 src

Test 2:

:~/EG/erlguten/priv$ cd /home/lloyd/EG/erlguten/priv/images
:~/EG/erlguten/priv/images$ ls -l
total 52
-rw-rw-r-- 1 lloyd lloyd 52820 Dec  3 14:12 book_cover.jpg

But but file:list_dir/1 doesn't:

1> Priv = code:priv_dir(erlguten).
"/home/lloyd/Erlang/erlguten/priv"
2>
2> Images = Priv ++ "/images".
"/home/lloyd/Erlang/erlguten/priv/images"
3>
3> file:list_dir(Priv).
{ok,["hyphenation","font_locations","fonts","src"]}
4>
4> file:list_dir(Images).
{error,enoent}

Note: erl started with

:~/EG/erlguten$ -pa ebin -pa lib/*/ebin

Here's the bash listing for ~/EG/erlguten:

:~/EG/erlguten$ ls -l
total 260
-rw-rw-r--  1 lloyd lloyd  17376 Nov  1 18:48 comcast_bill.pdf
drwxrwxr-x  2 lloyd lloyd   4096 Nov  2 19:10 deps
drwxrwxr-x  2 lloyd lloyd   4096 Nov  1 16:45 doc
drwxrwxr-x  2 lloyd lloyd   4096 Nov 29 17:12 ebin
drwxrwxr-x  2 lloyd lloyd   4096 Nov 30 18:31 include
-rw-rw-r--  1 lloyd lloyd     32 Nov  1 16:45 install.mk
drwxrwxr-x  3 lloyd lloyd   4096 Nov  1 17:42 lib
-rw-rw-r--  1 lloyd lloyd   1157 Nov  1 16:45 LICENSE
-rw-rw-r--  1 lloyd lloyd    206 Nov  1 16:45 Makefile
drwxrwxr-x  6 lloyd lloyd   4096 Dec  6 12:47 priv
-rw-rw-r--  1 lloyd lloyd   7208 Nov  1 16:45 readme.md
-rwxrwxr-x  1 lloyd lloyd 175879 Nov  2 16:56 rebar
-rw-rw-r--  1 lloyd lloyd    201 Nov  1 17:42 rebar.config
drwxrwxr-x 11 lloyd lloyd   4096 Dec  2 16:19 src
drwxrwxr-x  4 lloyd lloyd   4096 Nov 30 18:28 test

I've tried rebooting, but that doesn't solve the problem.

Are my aging eyes missing something? Or my aging brain overlooking something obvious? 

In short, how can I return images to my application?

Many thanks,

LRP







More information about the erlang-questions mailing list