Chapter 14. Directory Operations
Linux, like many other operating systems, uses directories to organize files. Directories (which are just special types of files that contain lists of file names) contain files, as well as other directories, allowing a file hierarchy to be built. All Linux systems have a root directory, known as /, through which (directly or indirectly) you access all the files on the system.
The Current Working Directory
Finding the Current Working Directory
The getcwd()
function allows a process to find the name of its current directory relative to the system’s root directory.
#include <unistd.h> char * getcwd(char * buf, size_t size);
The first parameter, buf
, points to a buffer that is filled in with the path to the current working ...
Get Linux Application Development, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.