|
a/src/utils/pathut.cpp |
|
b/src/utils/pathut.cpp |
1 |
#ifndef lint
|
1 |
#ifndef lint
|
2 |
static char rcsid[] = "@(#$Id: pathut.cpp,v 1.16 2007-06-08 15:30:01 dockes Exp $ (C) 2004 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: pathut.cpp,v 1.17 2007-09-08 08:07:05 dockes Exp $ (C) 2004 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
/*
|
4 |
/*
|
5 |
* This program is free software; you can redistribute it and/or modify
|
5 |
* This program is free software; you can redistribute it and/or modify
|
6 |
* it under the terms of the GNU General Public License as published by
|
6 |
* it under the terms of the GNU General Public License as published by
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
... |
|
... |
34 |
using std::stack;
|
34 |
using std::stack;
|
35 |
#endif /* NO_NAMESPACES */
|
35 |
#endif /* NO_NAMESPACES */
|
36 |
|
36 |
|
37 |
#include "pathut.h"
|
37 |
#include "pathut.h"
|
38 |
|
38 |
|
|
|
39 |
#include <sys/types.h>
|
39 |
#ifndef STATFS_INCLUDE
|
40 |
#ifndef STATFS_INCLUDE
|
40 |
#define STATFS_INCLUDE <sys/vfs.h>
|
41 |
#define STATFS_INCLUDE <sys/vfs.h>
|
41 |
#endif
|
42 |
#endif
|
42 |
|
43 |
|
43 |
#include STATFS_INCLUDE
|
44 |
#include STATFS_INCLUDE
|
44 |
|
45 |
|
45 |
bool fsocc(const string &path, int *pc, long *blocks)
|
46 |
bool fsocc(const string &path, int *pc, long *blocks)
|
46 |
{
|
47 |
{
|
|
|
48 |
#ifdef sun
|
|
|
49 |
struct statvfs buf;
|
|
|
50 |
if (statvfs(path.c_str(), &buf) != 0) {
|
|
|
51 |
return false;
|
|
|
52 |
}
|
|
|
53 |
#else
|
47 |
struct statfs buf;
|
54 |
struct statfs buf;
|
48 |
if (statfs(path.c_str(), &buf) != 0) {
|
55 |
if (statfs(path.c_str(), &buf) != 0) {
|
49 |
return false;
|
56 |
return false;
|
50 |
}
|
57 |
}
|
|
|
58 |
#endif
|
|
|
59 |
|
51 |
// used blocks
|
60 |
// used blocks
|
52 |
double fpc = 0.0;
|
61 |
double fpc = 0.0;
|
53 |
#define FSOCC_USED (double(buf.f_blocks - buf.f_bfree))
|
62 |
#define FSOCC_USED (double(buf.f_blocks - buf.f_bfree))
|
54 |
#define FSOCC_TOTAVAIL (FSOCC_USED + double(buf.f_bavail))
|
63 |
#define FSOCC_TOTAVAIL (FSOCC_USED + double(buf.f_bavail))
|
55 |
if (FSOCC_TOTAVAIL > 0) {
|
64 |
if (FSOCC_TOTAVAIL > 0) {
|