aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorjohnvg2010-10-13 13:23:20 +0000
committerjohnvg2010-10-13 13:23:20 +0000
commita656c005861c7491b1cac9bf33ff325b3ab4f545 (patch)
tree4065cf8e1887289dd99f2f0507d51aa2d7dd092a /main
parent#include <string.h> to prevent c compiler warnings (diff)
add prototype of function findNextFileC, don't use c++ comments
git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@1806 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d
Diffstat (limited to 'main')
-rw-r--r--main/Unix/cDirectory.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/main/Unix/cDirectory.c b/main/Unix/cDirectory.c
index 842020e..ccda618 100644
--- a/main/Unix/cDirectory.c
+++ b/main/Unix/cDirectory.c
@@ -17,7 +17,7 @@
#define FALSE 0
#define TRUE (!FALSE)
-// error codes:
+/* error codes: */
#define NoDirError 0
#define OtherDirError -1
#define DoesntExist -2
@@ -74,13 +74,15 @@ static int openSearch(const char *path, int length)
gpDir = (struct DIR*) opendir(gPath);
if (!gpDir)
return unix_error_to_clean_error(errno);
- gPath[gPathLength] = '/'; // filename will be added later
+ gPath[gPathLength] = '/'; /* filename will be added later */
gUserId = getuid();
gGroupId = getgid();
return NoDirError;
};
}
+int findNextFileC (int);
+
int findFirstFileC(CleanString cs_path)
{
int errCode;
@@ -97,7 +99,7 @@ void getCommonFileInfoC(int also_get_file_name,
int *pYear, int *pMonth, int *pDay, int *pDayNr,
int *pHours, int *pMinutes, int *pSeconds,
int *pIsDirectory, int *pIsReadOnly)
-// requires gFileName and gFileStat to be initialized
+/* requires gFileName and gFileStat to be initialized */
{
struct tm *pModificationTime;
int mask;
@@ -122,7 +124,7 @@ void getCommonFileInfoC(int also_get_file_name,
}
int findNextFileC(int dummy)
-// return values: 0=ok, 1=no further files in directory
+/* return values: 0=ok, 1=no further files in directory */
{
int i;
@@ -156,8 +158,8 @@ void getMacFileInfoC()
{}
void getUnixFileInfoC(int *pModeBits, int *pOwnerUserId, int *pOwnerGroupId,
- int *pLAYear, int *pLAMonth, int *pLADay, int *pLADayNr, // last access time
- int *pLAHours, int *pLAMinutes, int *pLASeconds) // dito
+ int *pLAYear, int *pLAMonth, int *pLADay, int *pLADayNr, /* last access time */
+ int *pLAHours, int *pLAMinutes, int *pLASeconds) /* dito */
{
struct tm *pModificationTime;
@@ -197,7 +199,7 @@ int findSingleFileC(CleanString cs_path)
i = CleanStringLength(cs_path)-2;
while (i>=0 && path_chars[i]!='/')
i--;
- // the last path element ranges from path_chars[i+1] to path_chars[CleanStringLength(cs_path)-2]
+ /* the last path element ranges from path_chars[i+1] to path_chars[CleanStringLength(cs_path)-2] */
length = CleanStringLength(cs_path)-2-i;
CleanStringLength(gFileName) = length;
@@ -215,7 +217,7 @@ int createDirectoryC(CleanString cs_path)
err = mkdir(CleanStringCharacters(cs_path),
S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
- // access rights for newly created directory: rwx--x--x
+ /* access rights for newly created directory: rwx--x--x */
if (err)
return unix_error_to_clean_error(errno);
else
@@ -237,7 +239,7 @@ int fremoveC(CleanString cs_path)
return NoDirError;
}
-// Try this code with slackware linux, if the testLinux program doesn't work
+/* Try this code with slackware linux, if the testLinux program doesn't work
//int fremoveC(CleanString cs_path)
//{
// int err;
@@ -257,6 +259,7 @@ int fremoveC(CleanString cs_path)
// else
// return NoDirError;
//}
+*/
#define OK 0
#define STRING_TOO_SMALL 1
@@ -264,7 +267,7 @@ int fremoveC(CleanString cs_path)
int getCurrentDirectory_SE(CleanString cs)
{
if (getcwd(CleanStringCharacters(cs), CleanStringLength(cs))) {
- // success. convert C String to Clean string
+ /* success. convert C String to Clean string */
int i;
i = 0;
while(CleanStringCharacters(cs)[i]!='\0')
@@ -273,10 +276,10 @@ int getCurrentDirectory_SE(CleanString cs)
return OK;
}
else {
- // failure
+ /* failure */
if (errno==EACCES) {
- // the permission to read the current directory was denied (how ever)
- // return root directory
+ /* the permission to read the current directory was denied (how ever)
+ return root directory */
CleanStringLength(cs) = 1;
CleanStringCharacters(cs)[0] = '/';
return OK;
@@ -320,8 +323,8 @@ int fmoveC(int overwrite, CleanString from, CleanString to)
if (overwrite) {
err = rename(CleanStringCharacters(from), CleanStringCharacters(to));
if (err && errno==ENOTDIR) {
- // from is a directory and to a file
- // try again after removing to
+ /* from is a directory and to a file
+ try again after removing to */
err = remove(CleanStringCharacters(to));
if (!err)
err = rename(CleanStringCharacters(from), CleanStringCharacters(to));