BeOS: Porting UNIX Applications

Chapter 21: Files and Directories

Overview

In this chapter we will look at directory and file access. The discussion covers six general topics: general functions, streams, UNIX file descriptors, utility functions, file systems, and the select and poll functions. The first section deals with the general access functions, which allow you to set ownership and modes and rename files, among many other things. The second section deals with streams and describes the interface to files using the Standard C stream function set.

UNIX-style file descriptors are discussed in the third section. Then we'll take a look at some utility functions for accessing directories, getting information about files, and using file locking. We'll take a quick look at extracting information about file systems before finally taking a look at select and poll.

21.1 General Functions

Handling files from a user's perspective renaming, deleting, and navigating around directories involves a collection of routines not vastly different from the commands used within a shell. All are simple and easy to use, and we'll take a brief look at each one.

rename

The rename function is the same as the mv command. If you specify the name of a file or directory, it will be moved to the new location. The function prototype is specified in the unistd.h header as follows:

   #include    int rename(const char *old_name, const char *new_name);

The function returns zero on success, non-zero on failure. The error detail is returned in the global variable errno

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Digital Asset Management Software
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.