make sigar_file2str available ifdef WIN32

This commit is contained in:
Doug MacEachern 2006-12-31 00:02:50 +00:00
parent 19d6d8b361
commit 268864db4d

View File

@ -98,22 +98,6 @@ char *sigar_getword(char **line, char stop)
return res; return res;
} }
int sigar_file2str(const char *fname, char *buffer, int buflen)
{
int len;
int fd = open(fname, O_RDONLY);
if (fd < 0) {
return ENOENT;
}
len = read(fd, buffer, buflen);
buffer[len] = '\0';
close(fd);
return SIGAR_OK;
}
/* avoiding sprintf */ /* avoiding sprintf */
char *sigar_proc_filename(char *buffer, int buflen, char *sigar_proc_filename(char *buffer, int buflen,
@ -588,6 +572,22 @@ SIGAR_DECLARE(int) sigar_rpc_ping(char *host,
} }
#endif #endif
int sigar_file2str(const char *fname, char *buffer, int buflen)
{
int len;
int fd = open(fname, O_RDONLY);
if (fd < 0) {
return ENOENT;
}
len = read(fd, buffer, buflen);
buffer[len] = '\0';
close(fd);
return SIGAR_OK;
}
#ifdef WIN32 #ifdef WIN32
#define vsnprintf _vsnprintf #define vsnprintf _vsnprintf
#endif #endif