SunOS 2.8 fixes
This commit is contained in:
parent
ae2dcf0d39
commit
364c26d50d
@ -1,7 +1,8 @@
|
|||||||
include $(depth)/mk/commondefs
|
include $(depth)/mk/commondefs
|
||||||
include $(depth)/mk/localdefs
|
include $(depth)/mk/localdefs
|
||||||
|
|
||||||
ALL_CXXFLAGS = $(CXXFLAGS) $(COMMONCXXFLAGS) $(LOCALCXXFLAGS)
|
ALL_CXXFLAGS = $(CXXFLAGS) $(COMMONCXXFLAGS) $(LOCALCXXFLAGS) \
|
||||||
|
-DSTATFS_INCLUDE="<sys/statvfs.h>"
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CXX = g++
|
CXX = g++
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: pathut.cpp,v 1.16 2007-06-08 15:30:01 dockes Exp $ (C) 2004 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: pathut.cpp,v 1.17 2007-09-08 08:07:05 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -36,6 +36,7 @@ using std::stack;
|
|||||||
|
|
||||||
#include "pathut.h"
|
#include "pathut.h"
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
#ifndef STATFS_INCLUDE
|
#ifndef STATFS_INCLUDE
|
||||||
#define STATFS_INCLUDE <sys/vfs.h>
|
#define STATFS_INCLUDE <sys/vfs.h>
|
||||||
#endif
|
#endif
|
||||||
@ -44,10 +45,18 @@ using std::stack;
|
|||||||
|
|
||||||
bool fsocc(const string &path, int *pc, long *blocks)
|
bool fsocc(const string &path, int *pc, long *blocks)
|
||||||
{
|
{
|
||||||
|
#ifdef sun
|
||||||
|
struct statvfs buf;
|
||||||
|
if (statvfs(path.c_str(), &buf) != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
struct statfs buf;
|
struct statfs buf;
|
||||||
if (statfs(path.c_str(), &buf) != 0) {
|
if (statfs(path.c_str(), &buf) != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// used blocks
|
// used blocks
|
||||||
double fpc = 0.0;
|
double fpc = 0.0;
|
||||||
#define FSOCC_USED (double(buf.f_blocks - buf.f_bfree))
|
#define FSOCC_USED (double(buf.f_blocks - buf.f_bfree))
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: readfile.cpp,v 1.4 2007-06-02 08:30:42 dockes Exp $ (C) 2004 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: readfile.cpp,v 1.5 2007-09-08 08:07:05 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -32,6 +32,19 @@ using std::string;
|
|||||||
|
|
||||||
#include "readfile.h"
|
#include "readfile.h"
|
||||||
|
|
||||||
|
static void caterrno(string *reason)
|
||||||
|
{
|
||||||
|
if (reason) {
|
||||||
|
#ifdef sun
|
||||||
|
// Note: sun strerror is noted mt-safe ??
|
||||||
|
*reason += string("file_to_string: open failed: ") + strerror(errno);
|
||||||
|
#else
|
||||||
|
strerror_r(errno, errbuf, ERRBUFSZ);
|
||||||
|
*reason += string("file_to_string: open failed: ") + errbuf;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool file_to_string(const string &fn, string &data, string *reason)
|
bool file_to_string(const string &fn, string &data, string *reason)
|
||||||
{
|
{
|
||||||
#define ERRBUFSZ 200
|
#define ERRBUFSZ 200
|
||||||
@ -40,20 +53,14 @@ bool file_to_string(const string &fn, string &data, string *reason)
|
|||||||
|
|
||||||
int fd = open(fn.c_str(), O_RDONLY|O_STREAMING);
|
int fd = open(fn.c_str(), O_RDONLY|O_STREAMING);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
if (reason) {
|
caterrno(reason);
|
||||||
strerror_r(errno, errbuf, ERRBUFSZ);
|
|
||||||
*reason += string("file_to_string: open failed: ") + errbuf;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int n = read(fd, buf, 4096);
|
int n = read(fd, buf, 4096);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
if (reason) {
|
caterrno(reason);
|
||||||
strerror_r(errno, errbuf, ERRBUFSZ);
|
|
||||||
*reason += string("file_to_string: read failed: ") + errbuf;
|
|
||||||
}
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
@ -62,10 +69,7 @@ bool file_to_string(const string &fn, string &data, string *reason)
|
|||||||
try {
|
try {
|
||||||
data.append(buf, n);
|
data.append(buf, n);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
if (reason) {
|
caterrno(reason);
|
||||||
strerror_r(errno, errbuf, ERRBUFSZ);
|
|
||||||
*reason += string("file_to_string: out of memory? : ") +errbuf;
|
|
||||||
}
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user