WvStreams
include
wvpushdir.h
1
/* -*- Mode: C++ -*-
2
* Worldvisions Tunnel Vision Software:
3
* Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4
*
5
* WvPushDir -- A simple class to check the existance of a dir
6
* and to properly return the formatted path of the diir
7
*/
8
#ifndef __WVPUSHDIR_H
9
#define __WVPUSHDIR_H
10
11
#include "wverror.h"
12
13
#include <sys/types.h>
14
#include <dirent.h>
15
#include <errno.h>
16
17
#include <unistd.h>
18
19
class
WvPushDir
:
public
WvError
20
{
21
DIR *dir_handle;
22
char
*old_dir;
23
24
public
:
25
void
*
operator
new
(size_t)
26
{ abort(); }
27
28
WvPushDir
(
WvStringParm
new_dir)
29
{
30
#ifdef MACOS
31
old_dir =
static_cast<
char
*
>
(calloc(PATH_MAX,
sizeof
(
char
*)));
32
getcwd(old_dir, PATH_MAX);;
33
#else
34
old_dir = get_current_dir_name();
35
#endif
36
dir_handle = opendir(old_dir);
37
if
(chdir(new_dir) == -1)
38
errnum = errno;
39
}
40
41
~WvPushDir
()
42
{
43
chdir(old_dir);
44
closedir(dir_handle);
45
free(old_dir);
46
}
47
};
48
49
#endif
WvError
A variant of WvErrorBase suitable for embedding as a member of your own object, preferably called 'er...
Definition
wverror.h:90
WvFastString
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
Definition
wvstring.h:94
WvPushDir
Definition
wvpushdir.h:20
Generated by
1.9.8