O nás     Inzerce     KontaktSpolehlivé informace o IT již od roku 2011
Hledat
Nepřehlédněte: Nejlepší IT: Pozoruhodné IT produkty pro rok 2024 podruhé
Správa dokumentů
Digitální transformace
Informační systémy
Hlavní rubriky: Informační systémy, Mobilní technologie, Datová centra, Sítě, IT bezpečnost, Software, Hardware, Zkušenosti a názory, Speciály

Pozoruhodné IT produkty 2024 podruhé
E-knihy o IT zdarma
Manuál Linux
[Linux manuál]

realpath: vyřešit cestu

Originální popis anglicky: realpath - resolve a pathname

Návod, kniha: POSIX Programmer's Manual

STRUČNĚ

#include <stdlib.h>
 
 
char *realpath(const char *restrict file_name,
 
       char *restrict resolved_name );
 

POPIS / INSTRUKCE

The realpath() function shall derive, from the pathname pointed to by file_name, an absolute pathname that names the same file, whose resolution does not involve '.' , '..' , or symbolic links. The generated pathname shall be stored as a null-terminated string, up to a maximum of {PATH_MAX} bytes, in the buffer pointed to by resolved_name.
If resolved_name is a null pointer, the behavior of realpath() is implementation-defined.

NÁVRATOVÁ HODNOTA

Upon successful completion, realpath() shall return a pointer to the resolved name. Otherwise, realpath() shall return a null pointer and set errno to indicate the error, and the contents of the buffer pointed to by resolved_name are undefined.

CHYBY / ERRORY

The realpath() function shall fail if:
EACCES
Read or search permission was denied for a component of file_name.
EINVAL
The file_name argument is a null pointer.
EIO
An error occurred while reading from the file system.
ELOOP
A loop exists in symbolic links encountered during resolution of the path argument.
ENAMETOOLONG
The length of the file_name argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}.
ENOENT
A component of file_name does not name an existing file or file_name points to an empty string.
ENOTDIR
A component of the path prefix is not a directory.
 
The realpath() function may fail if:
ELOOP
More than {SYMLOOP_MAX} symbolic links were encountered during resolution of the path argument.
ENAMETOOLONG
Pathname resolution of a symbolic link produced an intermediate result whose length exceeds {PATH_MAX}.
ENOMEM
Insufficient storage space is available.
 
The following sections are informative.

PŘÍKLADY POUŽITÍ

Generating an Absolute Pathname

The following example generates an absolute pathname for the file identified by the symlinkpath argument. The generated pathname is stored in the actualpath array.
 
#include <stdlib.h> ... char *symlinkpath = "/tmp/symlink/file"; char actualpath [PATH_MAX+1]; char *ptr;
 
ptr = realpath(symlinkpath, actualpath);

APPLICATION USAGE

None.

RATIONALE

Since the maximum pathname length is arbitrary unless {PATH_MAX} is defined, an application generally cannot supply a resolved_name buffer with size {{PATH_MAX}+1}.

FUTURE DIRECTIONS

In the future, passing a null pointer to realpath() for the resolved_name argument may be defined to have realpath() allocate space for the generated pathname.

SOUVISEJÍCÍ

getcwd() , sysconf() , the Base Definitions volume of IEEE Std 1003.1-2001, <stdlib.h> Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
2003 IEEE/The Open Group
©2011-2024 BusinessIT.cz, ISSN 1805-0522 | Názvy použité v textech mohou být ochrannými známkami příslušných vlastníků.
Provozovatel: Bispiral, s.r.o., kontakt: BusinessIT(at)Bispiral.com | Inzerce: Best Online Media, s.r.o., zuzana@online-media.cz
O vydavateli | Pravidla webu BusinessIT.cz a ochrana soukromí | Používáme účetní program Money S3 | pg(8048)