#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
#include "nvim/ascii.h"
#include "nvim/charset.h"
#include "nvim/eval.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h"
#include "nvim/file_search.h"
#include "nvim/fileio.h"
#include "nvim/garray.h"
#include "nvim/memfile.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
#include "nvim/os/shell.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/quickfix.h"
#include "nvim/regexp.h"
#include "nvim/screen.h"
#include "nvim/strings.h"
#include "nvim/tag.h"
#include "nvim/types.h"
#include "nvim/vim.h"
#include "nvim/window.h"
Macros | |
#define | URL_SLASH 1 |
#define | URL_BACKSLASH 2 |
#define | MAXSUFLEN 30 |
#define MAXSUFLEN 30 |
#define URL_BACKSLASH 2 |
#define URL_SLASH 1 |
bool add_pathsep | ( | char * | p | ) |
Adds a path separator to a filename, unless it already ends in one.
true
if the path separator was added or already existed. false
if the filename is too long. Add a file to a file list. Accepted flags: EW_DIR add directories EW_FILE add files EW_EXEC add executable files EW_NOTFOUND add even when it doesn't exist EW_ADDSLASH add slash after directory name EW_ALLLINKS add symlink also when the referred file does not exist
f | filename |
int after_pathsep | ( | const char * | b, |
const char * | p | ||
) |
int append_path | ( | char * | path, |
const char * | to_append, | ||
size_t | max_len | ||
) |
char* concat_fnames | ( | const char * | fname1, |
const char * | fname2, | ||
bool | sep | ||
) |
Concatenate file names fname1 and fname2 into allocated memory.
Only add a '/' or '\' when 'sep' is true and it is necessary.
fname1 | is the first part of the path or filename |
fname2 | is the second half of the path or filename |
sep | is a flag to indicate a path separator should be added if necessary |
char* concat_fnames_realloc | ( | char * | fname1, |
const char * | fname2, | ||
bool | sep | ||
) |
Concatenate file names fname1 and fname2
Like concat_fnames(), but in place of allocating new memory it reallocates fname1. For this reason fname1 must be allocated with xmalloc, and can no longer be used after running concat_fnames_realloc.
fname1 | is the first part of the path or filename |
fname2 | is the second half of the path or filename |
sep | is a flag to indicate a path separator should be added if necessary |
Expand wildcards. Calls gen_expand_wildcards() and removes files matching 'wildignore'.
num_pat | is number of input patterns. | |
pat | is an array of pointers to input patterns. | |
[out] | num_file | is pointer to number of matched file names. |
[out] | file | is pointer to array of pointers to matched file names. |
flags | is a combination of EW_* flags. |
Invoke expand_wildcards() for one pattern
One should expand items like "%:h" before the expansion.
[in] | pat | Pointer to the input pattern. |
[out] | num_file | Resulting number of files. |
[out] | file | Array of resulting files. |
[in] | flags | Flags passed to expand_wildcards(). |
char_u* find_file_name_in_path | ( | char_u * | ptr, |
size_t | len, | ||
int | options, | ||
long | count, | ||
char_u * | rel_fname | ||
) |
Return the name of the file ptr[len] in 'path'. Otherwise like file_name_at_cursor().
rel_fname | file we are searching relative to |
char* fix_fname | ( | const char * | fname | ) |
Get the full resolved path for fname
Even filenames that appear to be absolute based on starting from the root may have relative paths (like dir/../subdir) or symlinks embedded, or even extra separators (//). This function addresses those possibilities, returning a resolved absolute path. For MS-Windows, this also expands names like "longna~1".
fname | is the filename to expand |
Free the list of files returned by expand_wildcards() or other expansion functions.
char* FullName_save | ( | const char * | fname, |
bool | force | ||
) |
Get an allocated copy of the full path to a file.
fname | is the filename to save |
force | is a flag to expand fname even if it looks absolute |
fname
or NULL when fname
is NULL. Generic wildcard expansion code.
Characters in pat that should not be expanded must be preceded with a backslash. E.g., "/path\ with\ spaces/my\*star*".
num_pat | is number of input patterns. | |
pat | is an array of pointers to input patterns. | |
[out] | num_file | is pointer to number of matched file names. |
[out] | file | is pointer to array of pointers to matched file names. |
flags | is a combination of EW_* flags used in expand_wildcards(). |
Get a pointer to one character past the head of a path name. Unix: after "/"; Win: after "c:\" If there is no head, path is returned.
const char* gettail_dir | ( | const char *const | fname | ) |
Find end of the directory name
[in] | fname | File name to process. |
"/path/file", "/path/dir/", "/path//dir", "/file" ^ ^ ^ ^
Finds the path tail (or executable) in an invocation.
[in] | invocation | A program invocation in the form: "path/to/exe [args]". |
[out] | len | Stores the length of the executable name. |
len
is not null, stores the length of the executable name.Returns true if path begins with characters denoting the head of a path (e.g. '/' on linux and 'D:' on windows).
path | The path to be checked. |
int match_suffix | ( | char_u * | fname | ) |
Set the case of the file name, if it already exists. This will cause the file name to remain exactly the same. Only required for file systems where case is ignored and preserved.
int path_fnamecmp | ( | const char * | fname1, |
const char * | fname2 | ||
) |
Compare two file names
Handles '/' and '\' correctly and deals with &fileignorecase option.
[in] | fname1 | First file name. |
[in] | fname2 | Second file name. |
int path_fnamencmp | ( | const char *const | fname1, |
const char *const | fname2, | ||
size_t | len | ||
) |
Compare two file names
Handles '/' and '\' correctly and deals with &fileignorecase option.
[in] | fname1 | First file name. |
[in] | fname2 | Second file name. |
[in] | len | Compare at most len bytes. |
FileComparison path_full_compare | ( | char_u *const | s1, |
char_u *const | s2, | ||
const bool | checkname, | ||
const bool | expandenv | ||
) |
Compare two file names.
s1 | First file name. Environment variables in this name will be expanded. |
s2 | Second file name. |
checkname | When both files don't exist, only compare their names. |
expandenv | Whether to expand environment variables in file names. |
int path_full_dir_name | ( | char * | directory, |
char * | buffer, | ||
size_t | len | ||
) |
Get the absolute name of the given relative directory.
directory | Directory name, relative to current directory. |
FAIL
for failure, OK
for success. void path_guess_exepath | ( | const char * | argv0, |
char * | buf, | ||
size_t | bufsize | ||
) |
Builds a full path from an invocation name argv0
, based on heuristics.
[in] | argv0 | Name by which Nvim was invoked. |
[out] | buf | Guessed full path to argv0 . |
[in] | bufsize | Size of buf . |
Checks if a path has a character path_expand can expand.
p | The path to expand. |
Checks if a path has a wildcard character including '~', unless at the end.
p | The path to expand. |
int path_head_length | ( | void | ) |
Returns the length of the path head on the current platform.
int path_is_absolute | ( | const char_u * | fname | ) |
Check if file fname
is a full (absolute) path.
TRUE
if "fname" is absolute. int path_is_url | ( | const char * | p | ) |
const char* path_next_component | ( | const char * | fname | ) |
Get the next path component of a path name.
fname | A file path. (Must be != NULL.) |
fname
doesn't contain a path separator, Try to find a shortname by comparing the fullname with dir_name
.
full_path | The full path of the file. |
dir_name | The directory to shorten relative to. |
full_path
if shortened.char* path_tail | ( | const char * | fname | ) |
Gets the tail (i.e., the filename segment) of a path fname
.
Get pointer to tail of "fname", including path separators.
Takes care of "c:/" and "//". That means path_tail_with_sep("dir///file.txt")
will return a pointer to "///file.txt"
.
fname | A file path. (Must be != NULL.) |
fname
, if there is any.fname
if it contains no path separator.Try to find a shortname by comparing the fullname with the current directory.
full_path | The full path of the file. |
full_path
if shortened.full_path
unchanged if no shorter name is possible.full_path
is NULL. bool path_with_extension | ( | const char * | path, |
const char * | extension | ||
) |
int path_with_url | ( | const char * | fname | ) |
Check if "fname" starts with "name://" or "name:\\".
fname | is the filename to test |
int pathcmp | ( | const char * | p, |
const char * | q, | ||
int | maxlen | ||
) |
char* save_abs_path | ( | const char * | name | ) |
Saves the absolute path.
name | An absolute or relative path. |
name
. Shorten the path of a file from "~/foo/../.bar/fname" to "~/f/../.b/fname" It's done in-place.
Shorten the path of a file from "~/foo/../.bar/fname" to "~/f/../.b/fname" "trim_len" specifies how many characters to keep for each directory. Must be 1 or more. It's done in-place.
int vim_FullName | ( | const char * | fname, |
char * | buf, | ||
size_t | len, | ||
bool | force | ||
) |
Save absolute file name to "buf[len]".
fname | filename to evaluate | |
[out] | buf | contains fname absolute path, or:
|
len | length of buf | |
force | flag to force expanding even if the path is absolute |
int vim_ispathlistsep | ( | int | c | ) |
int vim_ispathsep | ( | int | c | ) |
int vim_ispathsep_nocolon | ( | int | c | ) |