Search results for directory
System.tmp_dir/0 (function)
Writable temporary directory. Returns a writable temporary directory. Searches for directories in the follow...
System.user_home/0 (function)
User home directory. Returns the user home directory (platform independent).
File.cd/1 (function)
Sets the current working directory. The current working directory is set for the BEAM globally. This can lead to r...
System.cwd!/0 (function)
Current working directory, exception on error. Returns the current working directory or raises `RuntimeEr...
File.cd!/2 (function)
Changes the current directory to the given `path`, executes the given function and then reverts back to the p...
System.cwd/0 (function)
Current working directory. Returns the current working directory or `nil` if one is not available.
File.cp_r/3 (function)
...s the contents in `source` to `destination` recursively, maintaining the source directory structure and modes. If `source` is a file or a symbolic link to it, `destinat...
File.cwd/0 (function)
Gets the current working directory. In rare circumstances, this function can fail on Unix-like systems. It may hap...
File.mkdir_p/1 (function)
Tries to create the directory `path`. Missing parent directories are created. Returns `:ok` if successful, o...
File.rm_rf/1 (function)
Removes files and directories recursively at the given `path`. Symlinks are not followed but simply removed, ...
File.dir?/2 (function)
Returns `true` if the given path is a directory. This function follows symbolic links, so if a symbolic link points to a direct...
File.rename/2 (function)
...mes the `source` file to `destination` file. It can be used to move files (and directories) between directories. If moving a file, you must fully specify the `destination...
File.mkdir/1 (function)
Tries to create the directory `path`. Missing parent directories are not created. Returns `:ok` if successfu...
Kernel.SpecialForms.__DIR__/0 (macro)
Returns the absolute path of the directory of the current file as a binary. Although the directory can be accessed as `Pa...
Path.relative_to_cwd/2 (function)
Convenience to get the path relative to the current working directory. If, for some reason, the current working directory cannot be retrieved, this f...
Path.dirname/1 (function)
Returns the directory component of `path`.
File.ls/1 (function)
Returns the list of files in the given directory. Hidden files are not ignored and the results are *not* sorted. Since director...
Examples - Path.wildcard/2 (function)
Imagine you have a directory called `projects` with three Elixir projects inside of it: `elixir`, `ex_doc`, ...
Examples - File.rename/2 (function)
... Rename file "a.txt" to "b.txt" File.rename("a.txt", "b.txt") # Rename directory "samples" to "tmp" File.rename("samples", "tmp")
Path.basename/1 (function)
...ns the last component of the path or the path itself if it does not contain any directory separators.
Application.app_dir/1 (function)
Gets the directory for app. This information is returned based on the code path. Here is an examp...
File.rm_rf!/1 (function)
...es a `File.Error` exception in case of failures, otherwise the list of files or directories removed.
System.tmp_dir!/0 (function)
Writable temporary directory, exception on error. Same as `tmp_dir/0` but raises `RuntimeError` instead of r...
System.user_home!/0 (function)
User home directory, exception on error. Same as `user_home/0` but raises `RuntimeError` instead of...
File.read/1 (function)
...missing permission for reading the file, or for searching one of the parent directories * `:eisdir` - the named file is a directory * `:enotdir` - a component of ...
Path.safe_relative_to/2 (function)
Returns a relative path that is protected from directory-traversal attacks. See `safe_relative/2` for a non-deprecated version of this API.
Examples - Protocol.extract_protocols/1 (function)
# Get Elixir's ebin directory path and retrieve all protocols iex> path = Application.app_dir(:elixir, "e...
Examples - Protocol.extract_impls/2 (function)
# Get Elixir's ebin directory path and retrieve all protocols iex> path = Application.app_dir(:elixir, "e...
File.cp/3 (function)
...o one. `destination_file` must be a path to a non-existent file. If either is a directory, `{:error, :eisdir}` will be returned. The function returns `:ok` in case of su...
File.rmdir/1 (function)
...or `{:error, reason}` if an error occurs. It returns `{:error, :eexist}` if the directory is not empty.
Examples - File.touch!/2 (function)
...59, 59}}) ** (File.Error) could not touch "/fakedir/b.txt": no such file or directory File.touch!("/tmp/a.txt", 1544519753)
File.ln_s/2 (function)
Creates a symbolic link `new` to the file or directory `existing`. Returns `:ok` if successful, `{:error, reason}` otherwise. If the ...
Path.expand/1 (function)
...If a relative path is provided it is expanded relatively to the current working directory.
File.exists?/2 (function)
Returns `true` if the given path exists. It can be a regular file, directory, socket, symbolic link, named pipe, or device file. Returns `false` for symbolic...
Getting started - Library guidelines (extras)
...on how to build, compile, run tests, and so on. Libraries commonly have a `lib` directory, which includes Elixir source code, and a `test` directory. A `src` directory ma...
Config.import_config/1 (macro)
... error is raised. If file is a relative, it will be expanded relatively to the directory the current configuration file is in.
File.rm/1 (function)
...ng permission for the file or one of its parents * `:eperm` - the file is a directory and user is not super-user * `:enotdir` - a component of the file name is not...
File (module)
...Unix variants. For example, one can copy a file via `cp/3` and remove files and directories recursively via `rm_rf/1`. Paths given to functions in this module can be eith...
File.write/3 (function)
...file name does not exist * `:enotdir` - a component of the file name is not a directory; on some platforms, `:enoent` is returned instead * `:enospc` - there is ...
Code.delete_path/1 (function)
Deletes a path from the Erlang VM code path list. This is the list of directories the Erlang VM uses for finding module code. The list of files is managed per Er...
Code.delete_paths/1 (function)
Deletes a list of paths from the Erlang VM code path list. This is the list of directories the Erlang VM uses for finding module code. The list of files is managed per Er...
Code.append_path/2 (function)
Appends a path to the Erlang VM code path list. This is the list of directories the Erlang VM uses for finding module code. The list of files is managed per Er...
Code.prepend_path/2 (function)
Prepends a path to the Erlang VM code path list. This is the list of directories the Erlang VM uses for finding module code. The list of files is managed per Er...
Dependencies within an umbrella project - Dependencies and umbrella projects (extras)
... starts. Finally, copy the `kv` application we have built so far to the `apps` directory in our new umbrella project. The final directory structure should match the str...
Code.append_paths/2 (function)
Appends a list of `paths` to the Erlang VM code path list. This is the list of directories the Erlang VM uses for finding module code. The list of files is managed per Er...
Code.prepend_paths/2 (function)
...repends a list of `paths` to the Erlang VM code path list. This is the list of directories the Erlang VM uses for finding module code. The list of files is managed per Er...
The `File` module - IO and the file system (extras)
... For example, `File.rm/1` can be used to remove files, `File.mkdir/1` to create directories, `File.mkdir_p/1` to create directories and all their parent chain. There are ev...
Options - Record.extract/2 (function)
...ts the following optional, non-exclusive options: * `:includes` - (a list of directories as binaries) if the record being extracted depends on relative includes, th...
Path.safe_relative/2 (function)
Returns a relative path that is protected from directory-traversal attacks. The given relative path is sanitized by eliminating `..` and `.` comp...
Compilation - Modules and functions (extras)
...module definition will be available (provided that `iex` is started in the same directory the bytecode file is in): ```elixir iex> Math.sum(1, 2) 3 ```
Application (behaviour)
...on is a component implementing some specific functionality, with a standardized directory structure, configuration, and life cycle. Applications are *loaded*, *started*,...
Path.wildcard/2 (function)
...jacent `*`'s used as a single pattern will match all files and zero or more directories and subdirectories. * `[char1,char2,...]` - matches any of the characters li...
Tooling - Application (behaviour)
... able to package all of your source code as well as the Erlang VM into a single directory. Releases also give you explicit control over how each application is started an...
Generators and filters - Comprehensions (extras)
... generators and filters to be given. Here is an example that receives a list of directories and gets the size of each file in those directories: ```elixir dirs = ["/home/...
Our first project - Introduction to Mix (extras)
...uld have been `Kv`: ```console $ mix new kv --module KV ``` Mix will create a directory named `kv` with a few files in it: ```text * creating README.md * creating .fo...
Scripting mode - Modules and functions (extras)
...am` file was written to disk. Elixir projects are usually organized into three directories: * `_build` - contains compilation artifacts * `lib` - contains Elixir code...
Automatic code formatting - Introduction to Mix (extras)
...ormat` runs. To give the formatter a try, change a file in the `lib` or `test` directories to include extra spaces or extra newlines, such as `def hello do`, and then r...
Examples - Introduction to Mix (extras)
...kv.app` was generated. All compilation artifacts are placed inside the `_build` directory using the options defined in the `mix.exs` file. Once the project is compiled,...
Don't drink the kool aid - Dependencies and umbrella projects (extras)
... you simply need to move applications outside of the umbrella project's `apps/` directory and update the project's mix.exs file to no longer set the `build_path`, `confi...
Umbrella projects - Dependencies and umbrella projects (extras)
...heir own dependencies. Each child application must be defined inside the `apps` directory. Let's move inside the apps directory and start building `kv_server`. This time...
Understanding applications - Supervision trees and applications (extras)
...` file, including the `.app` file itself. An application has generally only two directories: `ebin`, for Elixir artifacts, such as `.beam` and `.app` files, and `priv`, wit...
Working with files - Code (module)
...code, which have the `.beam` extension and are typically found below the _build directory of a Mix project, see the functions in Erlang's [`:code`](`:code`) module.
Running tests - Introduction to Mix (extras)
...jects usually follow the convention of having a ` _test.exs` file in the `test` directory for each file in the `lib` directory. For this reason, we can already find a `t...
Options - System.cmd/3 (function)
... (regardless of buffer size) and without the EOL character * `:cd` - the directory to run the command in * `:env` - an enumerable of tuples containing environm...
Consolidation - Protocol (behaviour)
... has already been consolidated. One possible solution is to include compilation directories that are specific to your test environment in your mix.exs: def project do...
File.Stat (module)
... Its fields are: * `size` - size of file in bytes. * `type` - `:device | :directory | :regular | :other | :symlink`; the type of the file. * `access` - `:re...
Options - Kernel.ParallelCompiler.compile/2 (function)
...ch compilation cycle and group pass checker * `:dest` - the destination directory for the BEAM files. When using `compile/2`, this information is only used t...
Internal dependencies - Dependencies and umbrella projects (extras)
...h the existing `kv` application and the new `kv_server` application inside. The directory structure will look like this: + kv_umbrella + apps + kv ...
Trailing bang (`foo!`) - Naming conventions (extras)
...txt") ** (File.Error) could not read file no_such_file.txt: no such file or directory The version without `!` is preferred when you want to handle different outcome...
Exceptions for control-flow - Design-related anti-patterns (extras)
....print_file("invalid_file") could not read file "invalid_file": no such file or directory :ok ``` #### Refactoring To refactor this anti-pattern, as shown next, use `F...
Errors - try, catch, and rescue (extras)
...read!("unknown") ** (File.Error) could not read file "unknown": no such file or directory (elixir) lib/file.ex:272: File.read!/1 ``` At the end of the day, it's up ...
Assembling multiple releases - Configuration and releases (extras)
... our project and prepared them to run in production, all packaged into a single directory.
Releases - Configuration and releases (extras)
... To achieve this goal, Elixir provides releases. A release is a self-contained directory that consists of your application code, all of its dependencies, plus the whole...
Module attributes - Module (behaviour)
... to the folder containing the project's `mix.exs`, which is the current working directory, not the file where `@external_resource` is declared. If the external resource ...