File exist

From Erlang Community

(Difference between revisions)
Revision as of 08:14, 12 October 2007 (edit)
Andreas.hillqvist (Talk | contribs)

← Previous diff
Revision as of 07:11, 15 October 2007 (edit) (undo)
Andreas.hillqvist (Talk | contribs)

Next diff →
Line 1: Line 1:
-There are many ways to test if a file exists in Erlang. Here are some examples:+The function ''filelib:is_regular/1'' could be used to verify that an file do exist or dose not exist.
 + 
 +Here is a example:
<code> <code>
-case filelib:is_regular(Name) of+case filelib:is_regular(FileName) of
-true ->+ true ->
- io:format("File exist.\n");+ io:format("File exist.\n");
-false ->+ false ->
- io:format("File dose not exist.\n")+ io:format("File dose not exist.\n")
end end
</code> </code>
[[Category:CookBook]] [[Category:FileRecipes]] [[Category:CookBook]] [[Category:FileRecipes]]

Revision as of 07:11, 15 October 2007

The function filelib:is_regular/1 could be used to verify that an file do exist or dose not exist.

Here is a example:

case filelib:is_regular(FileName) of
    true ->
        io:format("File exist.\n");
    false ->
        io:format("File dose not exist.\n")
end
Erlang/OTP Projects
Personal tools