コード例 #1
0
ファイル: DU.C プロジェクト: OS2World/UTIL-DISK-DU-DF
unsigned long calc_dir(char *pathname)
{
  struct find_t  direntry;
  char apu[_MAX_PATH];
  int done;
  unsigned long sum=0;

  level++;
  strcpy(apu,pathname);
  strcat(apu,FILEMASK);
  done=_dos_findfirst(apu,_A_NORMAL+_A_RDONLY+_A_HIDDEN+_A_SYSTEM+
			  _A_SUBDIR+_A_ARCH,&direntry);
  while (!done) {
    sum+=direntry.size;
    if (direntry.size % cluster_size == 0) true_sum+=direntry.size;
     else true_sum+=cluster_size+direntry.size-(direntry.size%cluster_size);
    if (!(direntry.attrib&_A_SUBDIR)) file_counter++;
    if ((direntry.attrib  & _A_SUBDIR)&& (strcmp(direntry.name,".."))&&
	(strcmp(direntry.name,"."))) {
      strcpy(apu,pathname);
      strcat(apu,direntry.name);
      strcat(apu,"\\");
      sum+=calc_dir(apu);
    }
    done=_dos_findnext(&direntry);
  }
 if ((level<=sublevels+1)||(sublevels<=0)) printf("%7luk %s\n",sum/1024,pathname);
 level--;
 return sum;
}
コード例 #2
0
ファイル: fileos2.c プロジェクト: Albermg7/boost
void
file_dirscan( 
	char *dir,
	scanback func,
	void	*closure )
{
    PATHNAME f;
    string filespec[1];
    long handle;
    int ret;
    struct _find_t finfo[1];

    /* First enter directory itself */

    memset( (char *)&f, '\0', sizeof( f ) );

    f.f_dir.ptr = dir;
    f.f_dir.len = strlen(dir);

    dir = *dir ? dir : ".";

    /* Special case \ or d:\ : enter it */
    string_copy( filespec, dir );

    if( f.f_dir.len == 1 && f.f_dir.ptr[0] == '\\' )
 	    (*func)( closure, dir, 0 /* not stat()'ed */, (time_t)0 );
    else if( f.f_dir.len == 3 && f.f_dir.ptr[1] == ':' )
 	    (*func)( closure, dir, 0 /* not stat()'ed */, (time_t)0 );
    else
        string_push_back( filespec, '/' );

    string_push_back( filespec, '*' );

    /* Now enter contents of directory */

    if( DEBUG_BINDSCAN )
        printf( "scan directory %s\n", filespec->value );

    /* Time info in dos find_t is not very useful.  It consists */
    /* of a separate date and time, and putting them together is */
    /* not easy.  So we leave that to a later stat() call. */

    if( !_dos_findfirst( filespec->value, _A_NORMAL|_A_RDONLY|_A_SUBDIR, finfo ) )
    {
        string filename[1];
        string_new( filename );
        do
        {
            
            f.f_base.ptr = finfo->name;
            f.f_base.len = strlen( finfo->name );

            string_truncate( filename, 0 );
            path_build( &f, filename, 0 );
            (*func)( closure, filename->value, 0 /* not stat()'ed */, (time_t)0 );
        }
        while( !_dos_findnext( finfo ) );
        string_free( filename );
    }
}
コード例 #3
0
LPSTR DirectoryName(
/************************************************************************/
int 	iDirectory,
LPSTR 	lpName)
{
#ifdef WIN32

#else
int retc;
struct find_t dir;

retc = _dos_findfirst( "*.*", _A_SUBDIR, &dir );
while ( !retc )
	{
	if ( dir.attrib & _A_SUBDIR && dir.name[0] != '.' )
		{ // If this is a subdirectory
		if ( --iDirectory < 0 )
			{
			lstrcpy( lpName, dir.name );
			return( lpName );
			}
		}
	retc = _dos_findnext( &dir );
	}

#endif
return( NULL );
}
コード例 #4
0
ファイル: attrib.c プロジェクト: ErisBlastar/osfree
LOCAL void PROC do_mask (char *pathend) {
        static struct find_t fi;

        adds (pathend, mask);
        if (_dos_findfirst (path, findattr, &fi))
                return;

        do {    const char *p;
                p = fi.name-1; do p++; while (*p == '.');
                if (*p == '\0') continue;               /* name == dots */

                adds (pathend, fi.name); found++;
            {   ATTR attr = attr2str (OLD_ATTR, fi.attrib);

                if (*NEW_PART != '\0') {
                    attr = (attr & attr_keep) | attr_set;
                    if (_dos_setfileattr (path,
                                          attr2str (NEW_ATTR, attr)
                                          & (ATTR)~_A_SUBDIR)) {
                        sayerror (E_ACCESS, "access denied", path);
                        continue;
            }   }    }

                say (info, path);
        } while (_dos_findnext (&fi) == 0);
}
コード例 #5
0
int ReaDirArray(char *path)
{
      struct find_t ff;
      char pattern[67];
      struct DirEntry *base = &DirRoot;

      strcpy(pattern, path);
      if ('/' != LAST_CHAR(pattern) && '\\' != LAST_CHAR(pattern))
            strcat(pattern, "\\");
      strcat(pattern, "*.*");
      if (SUCCESS == _dos_findfirst(pattern, 0xff, &ff)) do
      {
            struct DirEntry *node;

            if (NULL == (node = malloc(sizeof(struct DirEntry))))
                  return ERROR;
            base->next = node;
            strcpy(base->fname, ff.name);
            node->next = NULL;
            *node->fname = '\0';
            base = node;
            
      } while (SUCCESS == _dos_findnext(&ff));
      return SUCCESS;
}
コード例 #6
0
ファイル: files.c プロジェクト: ErisBlastar/osfree
/*************************************
*
*  Search for a file in the given directory.
*
**************************************/
BOOL __far __pascal FindFile( char __far * szDir, char __far * szWildName, struct _find_t __far * FileInfo )
{
  char szFilesPath[_MAX_PATH];
  short int LastCharPos;

  /* First time through. */
  if( szDir != NULL )
  {
    /* Build full path for search directory and wild name of file. */
    _fstrcpy( szFilesPath, szDir );

    /* Is there already a dir. separator? */
    LastCharPos = ( _fstrlen( szFilesPath ) / sizeof(char) ) - 1;
    if( szFilesPath[LastCharPos] != DIR_CHAR_SEPARATOR )
    {
      _fstrcat( szFilesPath, DIR_STRING_SEPARATOR );
    }

    _fstrcat( szFilesPath, szWildName );
      
    if( !_dos_findfirst( szFilesPath, _A_NORMAL, FileInfo ) ) return TRUE;
  }

  /* No first time through. */
  else
  {
    if( !_dos_findnext( FileInfo ) ) return TRUE;
  }
  
  /* Failure. */
  return FALSE;
}
コード例 #7
0
ファイル: LBMCOMP.C プロジェクト: NonCreature0714/descent
void main(int argc, char * argv[])	{
	int numfiles = 0;
 	struct find_t find;
	char * cp;
	char * cp1;

	setbuf(stdout, NULL);	// unbuffered output via printf

	argv++; argc--;
	for (;argc--;argv++)
	{
		if( !_dos_findfirst( *argv, 0xffff, &find ) )
		{
			dofile( find.name );
			numfiles++;
			while( !_dos_findnext( &find ) )	{
				numfiles++;
				dofile( find.name );
			}
	 	}
	}

	if ( numfiles < 1 )	{
		printf( "lbmcomp- this program compresses bbm files by removing\n");
		printf( "unused chunks. The command line is the file specs\n" );
		printf( "to convert. ie.. lbmcomp john*.bbm adam*.bbm\n\n" );
		exit(1);
	}


}
コード例 #8
0
ファイル: WAVEDIT.CPP プロジェクト: jimmccurdy/ArchiveGit
void convert_files(const char *pName,
						 int nNewAmplitude,
						 int nPercent,
						 DWORD __huge *pdwHistogram,
						 int nNewBits,
						 const char *pExtension,
						 const char *pDestDir)
{
	struct _find_t findbuf;

	for (unsigned uRet = _dos_findfirst(pName, _A_NORMAL|_A_RDONLY, &findbuf);
		  uRet == 0;
		  uRet = _dos_findnext(&findbuf))
	{
		char cbDestName[_MAX_PATH];
		char *p;

	/*
	// Prepend the path we want.
	*/

		if (pDestDir == NULL)
		{
			*cbDestName = '\0';
		}
		else
		{
			strcpy(cbDestName, pDestDir);
			p = cbDestName + strlen(cbDestName);
			if (p[-1] != '\\' && p[-1] != ':')
			{
				*p++ = '\\';
				*p = 0;
			}
		}

		strcat(cbDestName, findbuf.name);

	/*
	// Append the extension we want.
	*/

		if ((p = strrchr(cbDestName, '.')) == NULL)
		{
			strcat(cbDestName, pExtension);
		}
		else
		{
			strcpy(p, pExtension);
		}

		convert_file(findbuf.name,
						 cbDestName,
						 nNewAmplitude,
						 nPercent,
						 pdwHistogram,
						 nNewBits);
	}
}
コード例 #9
0
ファイル: ffind.c プロジェクト: cixonline/ameol
/* Searches for the next file that matches the given filename pattern previously
 * specified by a call to Amuser_FindFirst.
 */
HFIND EXPORT WINAPI Amuser_FindNext( HFIND hFind, FINDDATA FAR * npFindData )
{
#ifdef WIN32
   return( _findnext( hFind, npFindData ) );
#else
   return( _dos_findnext( npFindData ) ? -1 : 0 );
#endif
}
コード例 #10
0
ファイル: emdir.c プロジェクト: OS2World/APP-WORDPROC-dvips
int ll_findnext (struct ll_findbuffer *buffer)
{
  int res;
  do {
    res = _dos_findnext ((struct find_t *)buffer);
    if (res != 0) return 0;
  } while ( (buffer->attrib&ll_attr) == 0);
  return 1;
}
コード例 #11
0
ファイル: MK386.C プロジェクト: BGCX261/zlmtank-svn-to-git
void find_source( char *fpath, char *fname ) {
    int fpath_len = strlen( fpath );
    struct find_t fb;

    if (!_dos_findfirst( strcat( fpath, fname), _A_NORMAL, &fb ) )
    do {
        fpath[ fpath_len ] = '\0';
        get_one_source( strcat( fpath, fb.name) );
    } while( ! _dos_findnext( &fb ) );
}
コード例 #12
0
ファイル: gema.c プロジェクト: CarlWright/gema
void
expand_wildcard ( const char* file_spec, COStream out ) {
/*  Expand wild card file name on MS-DOS.
    (On Unix, this is not needed because expansion is done by the shell.)
 */
#ifdef MSDOS						       
#if defined(_FIND_T_DEFINED)  /* Microsoft C on MS-DOS */
  struct _find_t fblk;
  if ( _dos_findfirst( file_spec, _A_NORMAL|_A_ARCH|_A_RDONLY, &fblk )
       == 0 ) {
    /* first match found */
    do {
      merge_pathnames( out, FALSE, file_spec, fblk.name, NULL );
      cos_putch( out, '\n' );
    }
    while ( _dos_findnext( &fblk ) == 0 );
  }
  else
#elif defined(_WIN32)  /* Microsoft C/C++ on Windows NT */
  struct _finddata_t fblk;
  long handle;
  handle = _findfirst( (char*)file_spec, &fblk );
  if ( handle != -1 ) {
    /* first match found */
    do {
      if ( !(fblk.attrib & _A_SUBDIR) ) {		   
	merge_pathnames( out, FALSE, file_spec, fblk.name, NULL );
	cos_putch( out, '\n' );
      }
    }
    while ( _findnext( handle, &fblk ) == 0 );
    _findclose( handle );
  }
  else
#elif defined(__TURBOC__)  /* Borland Turbo C */
  struct ffblk fblk;
  if ( findfirst( file_spec, &fblk, FA_ARCH|FA_RDONLY ) == 0 ) {
    /* first match found */
    do {
      merge_pathnames( out, FALSE, file_spec, fblk.ff_name, NULL );
      cos_putch( out, '\n' );
    }
    while ( findnext( &fblk ) == 0 );
  }
  else
#endif /* Borland */
  if ( strchr(file_spec,'*') != NULL )
    fprintf( stderr, "No match for \"%s\"\n", file_spec );
  else
#endif /* MSDOS */
  {
    cos_puts( out, file_spec );
    cos_putch( out, '\n' );
  } 
}
コード例 #13
0
ファイル: dirwrap.c プロジェクト: donfanning/syncterm
int	DLLCALL	glob(const char *pattern, int flags, void* unused, glob_t* glob)
{
    struct	find_t ff;
	size_t	found=0;
	char	path[MAX_PATH+1];
	char*	p;
	char**	new_pathv;

	if(!(flags&GLOB_APPEND)) {
		glob->gl_pathc=0;
		glob->gl_pathv=NULL;
	}

	if(_dos_findfirst((char*)pattern,(flags&GLOB_PERIOD) ? _A_HIDDEN : _A_NORMAL,&ff)!=0)
		return(GLOB_NOMATCH);

	do {
		if((flags&GLOB_PERIOD || ff.name[0]!='.') &&
			(!(flags&GLOB_ONLYDIR) || ff.attrib&_A_SUBDIR)) {
			if((new_pathv=realloc(glob->gl_pathv
				,(glob->gl_pathc+1)*sizeof(char*)))==NULL) {
				globfree(glob);
				return(GLOB_NOSPACE);
			}
			glob->gl_pathv=new_pathv;

			/* build the full pathname */
			SAFECOPY(path,pattern);
			p=getfname(path);
			*p=0;
			strcat(path,ff.name);

			if((glob->gl_pathv[glob->gl_pathc]=malloc(strlen(path)+2))==NULL) {
				globfree(glob);
				return(GLOB_NOSPACE);
			}
			strcpy(glob->gl_pathv[glob->gl_pathc],path);
			if(flags&GLOB_MARK && ff.attrib&_A_SUBDIR)
				strcat(glob->gl_pathv[glob->gl_pathc],"/");

			glob->gl_pathc++;
			found++;
		}
	} while(_dos_findnext(&ff)==0);
	_dos_findclose(&ff);

	if(found==0)
		return(GLOB_NOMATCH);

	if(!(flags&GLOB_NOSORT)) {
		qsort(glob->gl_pathv,found,sizeof(char*),glob_compare);
	}

	return(0);	/* success */
}
コード例 #14
0
ファイル: dirosi.c プロジェクト: ABratovic/open-watcom-v2
_WCRTLINK DIR_TYPE *readdir( DIR_TYPE *dirp )
{
    if( dirp == NULL || dirp->d_first == _DIR_CLOSED )
        return( NULL );
    if( dirp->d_first == _DIR_ISFIRST ) {
        dirp->d_first = _DIR_NOTFIRST;
    } else {
        if( _dos_findnext( (struct _find_t *)dirp->d_dta ) ) {
            return( NULL );
        }
    }
    return( dirp );
}
コード例 #15
0
BOOL COXFileList::Search()
	{
#ifdef WIN32
	COXFileSpec* pFile;
	WIN32_FIND_DATA fileData;
	HANDLE hFindFile;
	BOOL bFileFound(TRUE);
		
	hFindFile = FindFirstFile(m_path.GetPath(), &fileData);
	if(hFindFile != INVALID_HANDLE_VALUE)
		{
		while (bFileFound)
			{
			if (((fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) &&
				(fileData.cFileName[0] != _T('.')))
				{
				pFile = new COXFileSpec;
				pFile->SetFileName(fileData.cFileName);
				pFile->SetTime(CTime(fileData.ftLastWriteTime));
				ASSERT(fileData.nFileSizeHigh == 0);
				pFile->SetLength(fileData.nFileSizeLow);
				pFile->SetAttributes((CFile::Attribute)fileData.dwFileAttributes);
				m_fileArray.Add(pFile);
				}

			bFileFound = FindNextFile(hFindFile,&fileData);
			}
		FindClose(hFindFile);
		}
	return TRUE;

#else
	COXFileSpec* pFile;
	_find_t fileInfo;
	BOOL bFileFound;
	
	bFileFound = (_dos_findfirst(m_path.GetPath(), _A_NORMAL | _A_ARCH, &fileInfo) == 0);
	while (bFileFound)
		{
		pFile = new COXFileSpec;
		pFile->SetFileName(fileInfo.name);
		pFile->SetTime(CTime((WORD)fileInfo.wr_date, (WORD)fileInfo.wr_time));
		pFile->SetLength(fileInfo.size);
		pFile->SetAttributes((CFile::Attribute)fileInfo.attrib);
		m_fileArray.Add(pFile);
		bFileFound = (_dos_findnext(&fileInfo) == 0);
		}		
	return TRUE;
#endif
	}
コード例 #16
0
unsigned LocalFindNext( void *info, unsigned info_len )
/*****************************************************/
{
    unsigned        rc;

    rc = _dos_findnext( &Findbuf );
    if( !rc ) {
        makeDOSDTA( &Findbuf, info );
        return( 0 );
    } else {
        _dos_findclose( &Findbuf );
        return( -1 );
    }
}
コード例 #17
0
ファイル: findfile.c プロジェクト: gameplayer22/d2x-1
int	FileFindNext(FILEFINDSTRUCT *ffstruct)
{
	unsigned retval;

	if (!_FileFindFlag) return -1;

	retval = _dos_findnext(&_FileFindStruct);
	if (retval) return (int)retval;
	else {
		ffstruct->size = _FileFindStruct.size;
		strcpy(ffstruct->name, _FileFindStruct.name);
		return (int)retval;
	}	
}
コード例 #18
0
ファイル: wildcard.c プロジェクト: EleanorRobson/oracc
void 
_wildcard (int *argcp, char ***argvp)
{
  int i, old_argc, new_argc, new_alloc;
  char **old_argv, **new_argv;
  char line[256], *p, *q;
  struct find_t find;

  old_argc = *argcp; old_argv = *argvp;
  for (i = 1; i < old_argc; ++i)
    if (old_argv[i] != NULL && strpbrk (old_argv[i], "?*") != NULL)
      break;
  if (i >= old_argc)
    return;                 /* do nothing */
  new_argv = NULL; new_alloc = 0; new_argc = 0;
  for (i = 0; i < old_argc; ++i)
    {
      if (i == 0 || old_argv[i] == NULL
          || strpbrk (old_argv[i], "?*") == NULL
          || _dos_findfirst (old_argv[i], _A_NORMAL, &find) != 0)
        {
          WPUT (old_argv[i]);
        }
      else
        {
          strcpy (line, old_argv[i]);
          p = q = line;
          while (*q != 0)
            {
              if (*q == ':' || *q == '\\' || *q == '/')
                p = q + 1;
              ++q;
            }
          do  {
            if (strcmp (find.name, ".") != 0 &&
                strcmp (find.name, "..") != 0)
              {
                strcpy (p, find.name);
                q = xstrdup (line);
                WPUT (q);
              }
          } while (_dos_findnext (&find) == 0);
        }
    }
  WPUT (NULL); 
  --new_argc;
  *argcp = new_argc; *argvp = new_argv;
  return;
}
コード例 #19
0
ファイル: tuifs.c プロジェクト: AreaScout/vice
static struct file_list *file_list_read_nolfn(const char *path, const char *pattern)
{
    char *cwd = ioutil_current_dir();
    struct file_list *fl = NULL;
    struct find_t f;

    if (cwd == NULL) {
        return NULL;
    }

    if (ioutil_chdir(path) < 0) {
        goto end;
    }

    if (_dos_findfirst("*.*", (_A_NORMAL | _A_RDONLY | _A_HIDDEN | _A_SYSTEM | _A_SUBDIR | _A_ARCH), &f)) {
        goto end;
    }

    fl = file_list_create();

    /* (We skip `.' here.) */

    while (!_dos_findnext(&f)) {
        strlwr(f.name);
        if (pattern == NULL || (f.attrib & _A_SUBDIR)) {
            file_list_add_item(fl, f.name, (f.attrib & _A_SUBDIR) ? FT_DIR : FT_NORMAL);
            continue;
        }
        {
            char *p = lib_stralloc(pattern);
            char *element;

            element = strtok(p, ";");
            do {
                if (fnmatch(element, f.name, FNM_NOCASE) == 0) {
                    file_list_add_item(fl, f.name, (f.attrib & _A_SUBDIR) ? FT_DIR : FT_NORMAL);
                }
                element = strtok(NULL, ";");
            } while (element != NULL);
            lib_free(p);
        }
    }

    file_list_sort(fl);

end:
    ioutil_chdir(cwd);
    return fl;
}
コード例 #20
0
ファイル: dir.c プロジェクト: Azarien/open-watcom-v2
_WCRTLINK DIRENT_TYPE *__F_NAME(readdir,_wreaddir)( DIR_TYPE *dirp )
{
    if( dirp == NULL || dirp->d_first == _DIR_CLOSED )
        return( NULL );
    if( dirp->d_first == _DIR_ISFIRST ) {
        dirp->d_first = _DIR_NOTFIRST;
    } else {
        if( _dos_findnext( (struct _find_t *)dirp->d_dta ) ) {
            return( NULL );
        }
    }
#ifdef __WIDECHAR__
    filenameToWide( dirp );
#endif
    return( dirp );
}
コード例 #21
0
ファイル: list.c プロジェクト: avinashtrivedi/windows_command
void main(int count,char *argv[]){
   struct find_t q ;
   int a;
   if(count==1)
      argv[1]="*.*";
      a = _dos_findfirst(argv[1],1,&q);
      if(a==0){
         while (!a){
            printf(" %s\n", q.name);
            a = _dos_findnext(&q);
         }
      }
      else{
         printf("File not found");
      }
}
コード例 #22
0
ファイル: mklib.c プロジェクト: OS2World/LIB-VIDEO-MGL
int main(int argc,char *argv[])
{
	struct find_t	blk;
	char			basename[_MAX_PATH];
	char			suffix[_MAX_PATH] = "";
	char			findname[_MAX_PATH];
	char			findsuffix[_MAX_PATH];
	char			command[_MAX_PATH];
	int				id,result,suffixlen;
	FILE			*f;

	if (argc != 2 && argc != 3)
		return -1;
	strcpy(basename,argv[1]);
	if (argc > 2)
		strcpy(suffix,argv[2]);
	strcpy(findname,basename);
	strcat(findname,"*");
	strcat(findname,suffix);
	strcat(findname,".fnt");
	strcpy(findsuffix,suffix);
	strcat(findsuffix,".fnt");
	suffixlen = strlen(findsuffix);
	if ((f = fopen("font.rc","w")) == NULL)
		return -1;
	id = 1;
	result = _dos_findfirst(findname,_A_NORMAL,&blk);
	while (result == 0) {
		if (!(blk.attrib & _A_SUBDIR) &&
				strlen(blk.name) == strlen(findname)+1 &&
				stricmp(&blk.name[strlen(blk.name)-suffixlen],findsuffix) == 0) {
			fprintf(f,"%d FONT LOADONCALL MOVEABLE DISCARDABLE %s\n", id,blk.name);
			id++;
			}
		result = _dos_findnext(&blk);
		}
	fclose(f);

	sprintf(command,"cp empty.dll %s%s.fon", basename, suffix);
	system(command);

	sprintf(command,"c:\\c\\bc50\\bin\\brc -fe%s%s.fon font.rc", basename, suffix);
	system(command);

	unlink("font.rc");
	return 0;
}
コード例 #23
0
ファイル: attrib.c プロジェクト: ErisBlastar/osfree
LOCAL void PROC do_path (char *pathend) {
        struct find_t fi;

        do_mask (pathend); if (recurse == 0) return;

        adds (pathend, "*.*");
        if (_dos_findfirst (path, DIR_ATTR, &fi))
                return;

        do {    const char *p;
                if ((fi.attrib & _A_SUBDIR) == 0) continue;
                p = fi.name-1; do p++; while (*p == '.');
                if (*p == '\0') continue;               /* name == dots */

                do_path (adds (adds (pathend, fi.name), "\\"));
        } while (_dos_findnext (&fi) == 0);
}
コード例 #24
0
ファイル: trans.c プロジェクト: OS2World/LIB-VIDEO-MGL
static ibool loadfiles(const char *mask,int *numfiles)
/****************************************************************************
*
* Function:     loadfiles
* Parameters:   filename    - Name of files to look for
*               fileList    - Place to store the filenames
* Returns:      True on success, false on memory error
*
* Description:  Loads a list of all the filenames from the current
*               directory into the specified name list. Does not include
*               any subdirectories in the list.
*
****************************************************************************/
{
#if defined(__MSDOS__) || defined(__WINDOWS__)
    struct find_t   blk;
    int             result;
    uint            findAttr = _A_RDONLY | _A_ARCH;

    result = _dos_findfirst(mask,findAttr,&blk);
    while (result == 0) {
        if (!(blk.attrib & _A_SUBDIR)) {
            filenames[*numfiles] = strdup(blk.name);
            strlwr(filenames[*numfiles]);
            (*numfiles)++;
            if (*numfiles == MAX_FILES) {
                printf("Too many input files!\n");
                exit(1);
                }
            }
        result = _dos_findnext(&blk);
        }
#else
    filenames[*numfiles] = strdup(mask);
    (*numfiles)++;
    if (*numfiles == MAX_FILES) {
        printf("Too many input files!\n");
        exit(1);
        }
#endif
    return true;
}
コード例 #25
0
ファイル: frfinddb.C プロジェクト: ralfbrown/framepac
static FrList *find_files_DOS(const char *directory, const char *mask,
			       const char *extension,
			       bool strip_extension = true)
{
   if (!mask)
      mask = "*" ;
   if (!extension)
      extension = "*" ;
   struct find_t ffblk ;
   FrList *files = 0 ;
   size_t dirlen = strlen(directory) ;
   size_t masklen = strlen(mask) + 1 ;
   size_t buflen = dirlen + masklen + strlen(extension) + 2 ;
   FrLocalAlloc(char,fullname,1024,buflen) ;
   if (!fullname)
      {
      FrNoMemory("while getting disk directory") ;
      return 0 ;
      }
   memcpy(fullname,directory,dirlen) ;
   fullname[dirlen++] = '/' ;
   memcpy(fullname+dirlen,mask,masklen) ;
   if (*extension)
      {
      strcat(fullname,".") ;
      strcat(fullname,extension) ;
      }
   int found = _dos_findfirst(fullname,_A_NORMAL,&ffblk) ;
   while (found == 0)
      {
      char *period = strip_extension ? strchr(ffblk.name,'.')
	                             : strchr(ffblk.name,'\0') ;
      if (period)
	 {
	 int len = period - ffblk.name ;
	 pushlist(new FrString(ffblk.name,len),files) ;
	 }
      found = _dos_findnext(&ffblk) ;
      }
   FrLocalFree(fullname) ;
   return files->sort(string_compare) ;
}
コード例 #26
0
ファイル: QF.C プロジェクト: rbieber/quickfind
/******************************************************************************
 *
 *          Name:   walkdirs
 *      Synopsis:   void walkdirs(startdir);
 *                  PSTR startdir;          name of directory to start in.
 *
 *   Description:   starting at startdir, steps through all remaining
 *                  directories and calls filefind() to find files matching
 *                  a given szFileName.
 *
 *****************************************************************************/
void PASCAL walkdirs(PSTR szStartDir, BOOL bCurrent, int (PASCAL * fcn) (PSTR))
{
   struct _find_t files;
   int bDone, result = 0;

   if (chdir(szStartDir) == -1)
      return;

   ulTotal += (*fcn) (szFileName);
   bDone = _dos_findfirst("*.*", _A_SUBDIR | _A_HIDDEN, &files);

   while (!bDone) {
      if ((files.attrib & _A_SUBDIR) && *files.name != '.')
         walkdirs(files.name, 0, fcn);

      bDone = _dos_findnext(&files);
   }

   chdir("..");
}
コード例 #27
0
ファイル: EXTDIR.C プロジェクト: hervethouzard/divers_c
void main( int argc, char *argv[] )
{
    struct _find_t find;
    long size;

    /* Find first matching file, then find additional matches. */
    if( !_dos_findfirst( argv[1], 0xffff, &find ) )
    {
        printf( "%-12s   %-8s    %-8s   %-8s   %-9s   %s %s %s %s\n",
                "FILE", "SIZE", "TIME", "DATE", "KIND",
                "RDO", "HID", "SYS", "ARC" );
        size = fileinfo( &find );
    }
    else
    {
        printf( "  SYNTAX: EXTDIR <wildfilespec>" );
        exit( 1 );
    }
    while( !_dos_findnext( &find ) )
        size += fileinfo( &find );
    printf( "%-12s   %8ld\n\n", "Total", size );
    exit( 0 );
}
コード例 #28
0
ファイル: BACKMAP5.C プロジェクト: Arc0re/dukenukem3d
getfilenames(char *kind)
{
	short type;
	struct find_t fileinfo;

	if (strcmp(kind,"SUBD") == 0)
	{
		strcpy(kind,"*.*");
		if (_dos_findfirst(kind,_A_SUBDIR,&fileinfo) != 0)
			return(-1);
		type = 1;
	}
	else
	{
		if (_dos_findfirst(kind,_A_NORMAL,&fileinfo) != 0)
			return(-1);
		type = 0;
	}
	do
	{
		if ((type == 0) || ((fileinfo.attrib&16) > 0))
			if ((fileinfo.name[0] != '.') || (fileinfo.name[1] != 0))
			{
				if (menunamecnt < MAXMENUFILES)
				{
					strcpy(menuname[menunamecnt],fileinfo.name);
					menuname[menunamecnt][16] = type;
					menunamecnt++;
				}
				//else
				//   printmessage("Too many files! (max=MAXMENUFILES)");
			}
	}
	while (_dos_findnext(&fileinfo) == 0);

	return(0);
}
コード例 #29
0
ファイル: doslinux.c プロジェクト: ftnapps/nlmake
unsigned
_dos_findfirst (char *name, unsigned start, struct find_t *f)
{
  unsigned char p = strlen (name);
  strcpy (f->path, name);
  while ((!!p) && (name[p] != '/'))
    p--;
  if (!p)
    f->path[p++] = '.';
  f->path[p] = 0;
  while ((name[p] == '/') || (name[p] == '*'))
    p++;
  strcpy (f->fname, name + p);
  p = strlen (f->fname);
  while ((!!p) && f->fname[p - 1] == '*')
    p--;
  f->fname[p] = 0;
  f->dir = opendir (f->path);
  if (!f->dir)
    return (unsigned) -1;
  f->size = 0;
  f->name = NULL;
  return _dos_findnext (f);
}
コード例 #30
0
ファイル: MDIRTEST.C プロジェクト: cr1901/nwbackup
int main( int argc, char *argv[] ) {

  int filesFound = 0;
  int dirsFound = 0;

  int stackPos = 0;


  // Prime the pump - do the first findfirst on the root directory.

  paths[stackPos] = strdup( argv[1] );
  sprintf( filespec, "%s*.*", paths[stackPos] );
  unsigned int rc = _dos_findfirst( filespec, (_A_NORMAL | _A_SUBDIR), &fileInfos[stackPos] );

  while ( 1 ) {

    if ( rc == 0 ) {

      if ( fileInfos[stackPos].attrib & _A_SUBDIR ) {

        dirsFound++;

        // Exclude . and .. from the directory walk, or we will get nowhere fast.

        if ( strcmp(fileInfos[stackPos].name, ".") != 0 && strcmp(fileInfos[stackPos].name, ".." ) != 0 ) {

          int newPathLength = strlen( paths[stackPos] ) + strlen( fileInfos[stackPos].name ) + 2;
          paths[stackPos+1] = (char *)malloc( newPathLength );
          sprintf( paths[stackPos+1], "%s%s/", paths[stackPos], fileInfos[stackPos].name );

          stackPos++;


          // 32 might not be correct ..  it might be closer to 40 based on the maximum allowable
          // DOS path length.  This is close enough for demo code.

          if ( stackPos == 32 ) {
            puts( "Too many levels of directories" );
            break;
          }

          sprintf( filespec, "%s*.*", paths[stackPos] );
          rc = _dos_findfirst( filespec, (_A_NORMAL | _A_SUBDIR), &fileInfos[stackPos] );
          continue;

        }

      }

      else if ( ((fileInfos[stackPos].attrib & _A_NORMAL) == _A_NORMAL) || ((fileInfos[stackPos].attrib & _A_RDONLY) == _A_RDONLY) ) {
        filesFound++;
        printf( "%s%s\n", paths[stackPos], fileInfos[stackPos].name );
      }

      rc = _dos_findnext( &fileInfos[stackPos] );

    }

    else {

      free( paths[stackPos] );

      if ( stackPos == 0 ) {
        break;
      }

      --stackPos;

      rc = _dos_findnext( &fileInfos[stackPos] );

    }

  }

  printf( "Total subdirectories: %u, Total files: %u\n", dirsFound, filesFound );
  return 0;
}