summaryrefslogtreecommitdiff
path: root/src/file.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/file.cc')
-rw-r--r--src/file.cc41
1 files changed, 10 insertions, 31 deletions
diff --git a/src/file.cc b/src/file.cc
index 813a041..2224178 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -31,6 +31,9 @@
/*
* $Log$
+ * Revision 1.4 2005/06/14 18:58:35 deva
+ * *** empty log message ***
+ *
* Revision 1.3 2005/06/14 12:29:40 deva
* Incorporated the use of the Info object everywhere... also using the log functionality.
*
@@ -111,11 +114,11 @@ int File::Open()
}
fd = open(fname, O_CREAT | O_WRONLY | O_SYNC | O_EXCL, //| O_LARGEFILE
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
- num ++;
+ if(fd == -1) num ++;
// If more than 1000 files are created in one day, something is terribly wrong!
if(num > 1000) {
- info->error("Something is wrong with the path [%s]!\n", fname);
+ info->error("Something is wrong with the path [%s]!", fname);
exit(1);
}
@@ -123,7 +126,7 @@ int File::Open()
seqnum ++;
- info->log("Opened the file %s for output.", fname);
+ info->info("Outout file: %s", fname);
return 0;
}
@@ -135,11 +138,11 @@ int File::Write(void* data, int size)
w = write(fd, data, size);
if(w != size) {
- info->log("Wrapping file.\n");
+ info->info("Wrapping file.");
Open();
w = write(fd, data, size);
if(w != size) {
- info->error("Out of diskspace!\n");
+ info->error("Out of diskspace!");
return -1;
}
}
@@ -158,10 +161,10 @@ int File::createPath(char* path)
subpath[strrchr(subpath, '/') - subpath] = '\0';
- info->info("Checking and/or generating directory: %s", path);
-
if(strlen(subpath) > 0) createPath(subpath);
+ info->info("Checking and/or generating directory: %s", path);
+
// stat(path, &stats);
//if(!S_ISDIR(stats.st_mode) && S_ISREG(stats.st_mode))
mkdir(path, S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH | S_IROTH);
@@ -172,27 +175,3 @@ int File::createPath(char* path)
return 0;
}
-
-#ifdef FILE_TEST // Test
-#define BLOCK_SIZE 1024*1024
-#define TIMES 4000
-int main()
-{
- void *buf = malloc(BLOCK_SIZE);
-
- double b = BLOCK_SIZE;
- double t = TIMES;
-
- double gb = b / (1024 * 1024 * 1024);
- gb *= t;
-
- printf("Writing %f GB.\n", gb);
-
- File file("/tmp/filetest/folder1/folder2/file", "ext");
- for(int cnt = 0; cnt < TIMES; cnt++) {
- file.Write(buf, BLOCK_SIZE);
- }
-
- printf("Done.\n");
-}
-#endif // Test