summaryrefslogtreecommitdiff
path: root/cd-tool.cpp
diff options
context:
space:
mode:
authorPixel <Pixel>2002-05-23 14:07:46 +0000
committerPixel <Pixel>2002-05-23 14:07:46 +0000
commitbdbd7e1296b98081794e0b185a0b8b677c811359 (patch)
tree18b17064b2b5026d3272ac573b6728fed418c476 /cd-tool.cpp
parent983358288de02d3bbf09a007f67d6f7d01bc2eff (diff)
Again FILE * removing... this is boring!
Diffstat (limited to 'cd-tool.cpp')
-rw-r--r--cd-tool.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/cd-tool.cpp b/cd-tool.cpp
index 8cd5d6e..4b601ba 100644
--- a/cd-tool.cpp
+++ b/cd-tool.cpp
@@ -24,6 +24,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
+#include <unistd.h>
#include "cdutils.h"
#include "generic.h"
#include "fileutils.h"
@@ -57,7 +58,7 @@ void showhelp(void) {
int main(int argc, char ** argv) {
int type = GUESS, c, size, force = 0, sector;
- FILE * iso_r, * iso_w;
+ int iso_r, iso_w;
char * ppf = 0, * iso_name = 0, * arg1 = 0, * arg2 = 0, * f;
verbosity = M_WARNING;
@@ -89,7 +90,7 @@ int main(int argc, char ** argv) {
iso_name = argv[optind++];
- if (!(iso_r = fopen(iso_name, "r"))) {
+ if ((iso_r = open(iso_name, O_RDONLY)) < 0) {
printm(M_ERROR, "Failed to open %s for reading.\n", iso_name);
exit(-1);
}
@@ -129,7 +130,7 @@ int main(int argc, char ** argv) {
show_dir(iso_r, &dir);
} else if (!strcmp(argv[optind], "extract-file")) {
struct DirEntry dir;
- FILE * file;
+ int file;
optind++;
if ((argc - 2) != optind) {
@@ -139,7 +140,7 @@ int main(int argc, char ** argv) {
}
arg1 = argv[optind++];
arg2 = argv[optind++];
- if (!(file = fopen(arg1, "w"))) {
+ if ((file = open(arg1, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) {
printm(M_ERROR, "Failed to open file %s for writing.\n", arg1);
exit(-1);
}
@@ -152,7 +153,7 @@ int main(int argc, char ** argv) {
printm(M_STATUS, "Reading path %s to file %s.\n", arg2, arg1);
read_file(iso_r, file, type, dir.Sector, dir.Size);
} else if (!strcmp(argv[optind], "extract")) {
- FILE * file;
+ int file;
optind++;
if ((argc - 3) != optind) {
@@ -163,7 +164,7 @@ int main(int argc, char ** argv) {
arg1 = argv[optind++];
size = atoi(argv[optind++]);
sector = atoi(argv[optind++]);
- if (!(file = fopen(arg1, "w"))) {
+ if ((file = open(arg1, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) {
printm(M_ERROR, "Failed to open file %s for writing.\n", arg1);
exit(-1);
}
@@ -172,13 +173,13 @@ int main(int argc, char ** argv) {
} else if (!strcmp(argv[optind], "insert-file")) {
struct DirEntry dir, * d;
unsigned char * buffer;
- FILE * file;
+ int file;
int old_type;
- if (!(iso_w = fopen(iso_name, "wa"))) {
+ if ((iso_w = open(iso_name, O_WRONLY)) < 0) {
printm(M_ERROR, "Failed to open %s for writing.\n", iso_name);
exit(-1);
}
- fseek(iso_w, 0, SEEK_SET);
+ lseek(iso_w, 0, SEEK_SET);
if (ppf) {
if (open_ppf(ppf, iso_r, "Created by CD-Tool") < 0) {
@@ -194,7 +195,7 @@ int main(int argc, char ** argv) {
}
arg1 = argv[optind++];
arg2 = argv[optind++];
- if (!(file = fopen(arg1, "r"))) {
+ if ((file = open(arg1, O_RDONLY)) < 0) {
printm(M_ERROR, "Failed to open file %s for reading.\n", arg1);
exit(-1);
}
@@ -234,12 +235,12 @@ int main(int argc, char ** argv) {
write_datas(iso_r, iso_w, buffer, GUESS, dir.Sector, dir.Size);
free(buffer);
} else if (!strcmp(argv[optind], "insert")) {
- FILE * file;
- if (!(iso_w = fopen(iso_name, "wa"))) {
+ int file;
+ if ((iso_w = open(iso_name, O_WRONLY)) < 0) {
printm(M_ERROR, "Failed to open %s for writing.\n", iso_name);
exit(-1);
}
- fseek(iso_w, 0, SEEK_SET);
+ lseek(iso_w, 0, SEEK_SET);
if (ppf) {
if (open_ppf(ppf, iso_r, "Created by CD-Tool") < 0) {
@@ -255,7 +256,7 @@ int main(int argc, char ** argv) {
}
arg1 = argv[optind++];
sector = atoi(argv[optind++]);
- if (!(file = fopen(arg1, "r"))) {
+ if ((file = open(arg1, O_RDONLY)) < 0) {
printm(M_ERROR, "Failed to open file %s for reading.\n", arg1);
exit(-1);
}