06.08.2013 Views

pSOSystem System Calls - Read

pSOSystem System Calls - Read

pSOSystem System Calls - Read

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

pHILE+ <strong>System</strong> <strong>Calls</strong> stat_f<br />

Usage<br />

Hex Mnemonic Description<br />

0x207E ERPC All other RPC errors.<br />

stat_f() can be used to determine both the current device and the current<br />

directory of local volumes. Thus you can use stat_f() to return to a device and<br />

directory after leaving them, or to construct absolute path names starting at the<br />

current directory. Only the directory file number is available, not the full directory<br />

path. To obtain the full directory path, see get_fn().<br />

/* Obtaining both the current device and the current directory */<br />

ULONG rc; /* <strong>System</strong> call return code */<br />

struct stat current_stat; /* stat_f() of "." */<br />

ULONG device; /* Current device */<br />

ULONG directory; /* Current directory */<br />

if((rc = stat_f(".", &current_stat)) != 0)<br />

/* Error processing */<br />

device = current_stat.st_dev;<br />

directory = current_stat.st_dev;<br />

/* Returning to the above device and directory at a later time. */<br />

char directory[29]; /* To change back */<br />

sprintf(directory, "0x%04x.0x%02x.0x%02x.0x%08x/.",<br />

device >> 16, /* Major device number */<br />

(device >> 8) & 0xffU, /* Minor device number */<br />

device & 0xffU, /* Partition number */<br />

directory); /* File number to start at */<br />

if((rc = change_dir(directory)) != 0)<br />

/* Error processing */<br />

/* Constructing absolute path name starting at the saved directory */<br />

#define REL_PATH_LEN 8 /* Length of path below saved<br />

* directory */<br />

char path[28 + PATH_LEN]; /* Absolute path of file.txt */<br />

sprintf(path, "0x%04x.0x%02x.0x%02x.0x%08x/%s",<br />

device >> 16, /* Major device number */<br />

(device >> 8) & 0xffU, /* Minor device number */<br />

device & 0xffU, /* Partition number */<br />

<strong>pSO<strong>System</strong></strong> <strong>System</strong> <strong>Calls</strong> 2-107<br />

2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!