How to open file with relevant path in erlang? -
I am roaming with erlang and how can I read a .txt file with a function, It is not understandable how to read it from the path. Basically it is that I have created my project directories:
project / | Ebin / | Private / | Include / | Src / All my .bim files are in the ebin directory and I need to open the .txt file in the "./" directory.
This is my code:
by_file (filename) - & gt; {OK, BIN} = File: read_file (FileName), ... When I call this function, I give a string like: "/ absolute / path / To / project / directory / private "But I get this error every time. Exception error: function read_mxm: from_file / 1 (src / read_mxm.erl, {error, enoent} line 34 on right hand side) in call from mr_tests: wc / 0 (src / Mr_tests.erl, line 21)
If I have a .bxt file I'm calling the function so it works fine if I input only one file name as "foo.txt".
How can I work with the relevant path of this project?
If I can not do it this way, how can I read a file that is in the same directory with a .beam file?
For example
project / | Ebin / | | Folder_with_the_doc_that_I_want_to_read / | Private / | Include / | Eranga provides the task to determine the location of various application directories, including ebin and. Priv Use the function code: priv_dir (with a failover case), such as: read_priv_file (filename) - & gt; Case code: Private_dir (my_application) {error, bad_name} - & gt; % This happens when the release is not running; For example, erl -pa ebin% Of course, this will not work for all cases, but for most PrivDir = "priv", there should be a% account; PrivDir - & gt; % In this case, we are running in a release and VM knows where the file (file name :: ([PrivDir, Filename]) is included in the application, and finally the application on the file system (and thus the private directory)
Comments
Post a Comment