1
1

MC for OS/2 shows hidden and system files now

Этот коммит содержится в:
Pavel Machek 1998-04-19 02:57:57 +00:00
родитель 83b792b299
Коммит a754100836
2 изменённых файлов: 46 добавлений и 95 удалений

Просмотреть файл

@ -11,14 +11,6 @@ extern "C" {
#include <sys/types.h>
#ifdef __os2__
#ifndef __OS2_H__
#define INCL_DOSFILEMGR
#define INCL_DOSERRORS
#include <os2.h>
#endif
#endif /* __os2__ */
#define NAME_MAX 255 /* maximum filename for HPFS or NTFS */
typedef struct dirent {
@ -32,29 +24,9 @@ typedef struct dirent {
char d_first; /* flag for 1st time */
} DIR;
#ifndef _A_NORMAL
#define _A_NORMAL 0x00 /* Normal file - read/write permitted */
#define _A_RDONLY 0x01 /* Read-only file */
#define _A_HIDDEN 0x02 /* Hidden file */
#define _A_SYSTEM 0x04 /* System file */
#define _A_VOLID 0x08 /* Volume-ID entry */
#define _A_SUBDIR 0x10 /* Subdirectory */
#define _A_ARCH 0x20 /* Archive file */
#endif /* _A_NORMAL_ */
extern int closedir( DIR * );
/*
extern char *getcwd( char *__buf, unsigned __size );
extern unsigned _getdrive( void );
extern unsigned _getdiskfree( unsigned __drive, struct _diskfree_t *__diskspace);
*/
extern DIR *opendir( const char * );
extern struct dirent *readdir( DIR * );
#if !defined(__os2__)
extern int chdir( const char *__path );
extern int mkdir( const char *__path );
extern int rmdir( const char *__path );
#endif
#ifdef __cplusplus
};

Просмотреть файл

@ -1,15 +1,16 @@
#define INCL_DOSFILEMGR
#define INCL_DOSERRORS
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#define INCL_DOSFILEMGR
#define INCL_DOSERRORS
#include <os2.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dirent.h"
#include <errno.h>
#include "dirent.h"
DIR *opendir (const char * a_dir)
{
@ -21,42 +22,34 @@ DIR *opendir (const char * a_dir)
strcpy (c_dir, a_dir);
strcat (c_dir, "\\*.*");
dd_dir->d_handle = HDIR_CREATE;
dd_dir->d_handle = (unsigned long*) HDIR_CREATE;
rc = DosFindFirst(c_dir,
(PHDIR) &dd_dir->d_handle,
/* FILE_NORMAL || FILE_DIRECTORY, */
FILE_DIRECTORY,
(PVOID) &FindBuffer,
sizeof(FILEFINDBUF3),
&FileCount,
FIL_STANDARD);
(PHDIR) &dd_dir->d_handle,
FILE_SYSTEM | FILE_HIDDEN | FILE_DIRECTORY,
(PVOID) &FindBuffer,
sizeof(FILEFINDBUF3),
&FileCount,
FIL_STANDARD);
switch (rc) {
case ERROR_NO_MORE_FILES:
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
errno = ENOENT;
free(dd_dir);
return NULL;
break;
case ERROR_BUFFER_OVERFLOW:
errno = ENOMEM;
free(dd_dir);
return NULL;
break;
case NO_ERROR: /* go through */
break;
default:
errno = EINVAL;
free(dd_dir);
return NULL;
break;
if (rc) {
switch (rc) {
case ERROR_NO_MORE_FILES:
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
errno = ENOENT;
break;
case ERROR_BUFFER_OVERFLOW:
errno = ENOMEM;
break;
default:
errno = EINVAL;
break;
}
free(dd_dir);
return NULL;
}
dd_dir->d_attr = FindBuffer.attrFile;
/* dd_dir->d_attr = (wfd.dwFileAttributes == FILE_ATTRIBUTE_NORMAL)
? 0 : wfd.dwFileAttributes; */
dd_dir->d_time = dd_dir->d_date = 10;
dd_dir->d_size = FindBuffer.cbFile;
strcpy (dd_dir->d_name, FindBuffer.achName);
@ -83,49 +76,35 @@ DIR *readdir( DIR * dd_dir)
sizeof(FILEFINDBUF3),
&FileCount);
switch (rc) {
case ERROR_NO_MORE_FILES:
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
errno = ENOENT;
return NULL;
break;
case ERROR_BUFFER_OVERFLOW:
errno = ENOMEM;
return NULL;
break;
case NO_ERROR: /* go through */
break;
default:
errno = EINVAL;
return NULL;
break;
if (rc) {
switch (rc) {
case ERROR_NO_MORE_FILES:
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
errno = ENOENT;
break;
case ERROR_BUFFER_OVERFLOW:
errno = ENOMEM;
break;
default:
errno = EINVAL;
break;
}
return NULL;
}
/* dd_dir->d_attr = (wfd.dwFileAttributes == FILE_ATTRIBUTE_NORMAL)
? 0 : wfd.dwFileAttributes; */
/* #define FILE_NORMAL 0x0000
#define FILE_READONLY 0x0001
#define FILE_HIDDEN 0x0002
#define FILE_SYSTEM 0x0004
#define FILE_DIRECTORY 0x0010
#define FILE_ARCHIVED 0x0020
*/
ret_dir->d_attr = FindBuffer.attrFile;
ret_dir->d_time = ret_dir->d_date = 10;
ret_dir->d_size = FindBuffer.cbFile;
ret_dir->d_size = FindBuffer.cbFile;
strcpy (ret_dir->d_name, FindBuffer.achName);
return ret_dir;
}
int closedir (DIR *dd_dir)
{
if (dd_dir->d_handle != HDIR_CREATE) {
if (dd_dir->d_handle != (unsigned long*) HDIR_CREATE) {
DosFindClose((HDIR) dd_dir->d_handle);
}
free (dd_dir);
return 1;
}