summaryrefslogtreecommitdiff
path: root/archivers/libcabinet/files/patch-listcab.cpp
blob: c46f051b7ae84deb61a20d4e7378dbe0ae8c0476 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
--- listcab.cpp.orig	1999-10-24 12:11:38 UTC
+++ listcab.cpp
@@ -8,8 +8,8 @@
 #include <stdio.h>
 #include <string.h>
 //#include <iomanip.h>
-#include <fstream.h>
-#include <iostream.h>
+#include <fstream>
+#include <iostream>
 #include "cftypes.h"
 #include "cfheader.h"
 #include "cffolder.h"
@@ -19,6 +19,10 @@
 #include "cfreader.h"
 #include "cfcreate.h"
 
+using std::endl;
+using std::cout;
+using std::cerr;
+
 ////////////////////////////////////////****************************************
 
 void display_header_info(cabinet_header& cfh);
@@ -47,13 +51,19 @@ int main(int argc, char *argv[])
 			cerr << "New Folder Error: " << retval << endl;
 			return 1;
 		}
-
+		int n;
 		do{
 			cout << "Enter filename: ";
-			gets(filename);
-
-			if(strlen(filename) > 0)
+			fgets(filename, 256, stdin);
+			n = strlen (filename);
+			
+			if (n == 1 && filename[0] == '\n')
+				n = 0;
+			
+			if(n > 0)
 			{
+				if (filename[n-1] == '\n')
+					filename[n-1] = '\0';
 				if((retval = cab.add_file(filename)) != OK)
 				{
 					perror("read");
@@ -62,10 +72,13 @@ int main(int argc, char *argv[])
 					return 1;
 				}
 			}
-		}while(strlen(filename) > 0);
+		}while(n > 0);
 
 		cout << "Enter filename for cabinet: ";
-		gets(filename);
+		fgets(filename, 256, stdin);
+		n = strlen (filename);
+		if (n > 0 && filename[n-1] == '\n')
+			filename[n-1] = '\0';
 
 		if((retval = cab.close(filename)) != OK)
 		{