home *** CD-ROM | disk | FTP | other *** search
- head 0.5;
- access;
- symbols;
- locks
- simons:0.5; strict;
- comment @ * @;
-
-
- 0.5
- date 93.12.08.17.15.53; author simons; state Exp;
- branches;
- next 0.4;
-
- 0.4
- date 93.12.08.17.08.46; author simons; state Exp;
- branches;
- next 0.3;
-
- 0.3
- date 93.12.04.21.55.27; author simons; state Exp;
- branches;
- next 0.2;
-
- 0.2
- date 93.12.04.21.52.40; author simons; state Exp;
- branches;
- next 0.1;
-
- 0.1
- date 93.12.04.20.45.42; author simons; state Exp;
- branches;
- next ;
-
-
- desc
- @Subroutines handling directory scanning.
- @
-
-
- 0.5
- log
- @InitScanDir() didn't reallocate the buffer in an overflow sitation,
- causing a system crash. :-) This is fixed now.
- @
- text
- @/*
- * $Filename: ScanDir.c $
- * $Revision: 0.4 $
- * $Date: 1993/12/08 17:08:46 $
- *
- * Copyright (C) 1993 by Peter Simons <simons@@peti.GUN.de>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: ScanDir.c,v 0.4 1993/12/08 17:08:46 simons Exp simons $
- *
- * ------------------------------ log history ----------------------------
- * $Log: ScanDir.c,v $
- * Revision 0.4 1993/12/08 17:08:46 simons
- * AmigaOS's filesystem used to have a bug in versions earlier than 40.x,
- * that may cause corrupted blocks and even crashes if files are deleted
- * or renamed while the ExNext()-scan is in progress. Therefore I changed
- * the directory scan. Now, the directory is read completly and all names
- * buffered.
- * Thanks to Frank Bergknecht <frank@@dino.dinoco.de> for drawing my
- * attention to this.
- *
- * Revision 0.3 1993/12/04 21:55:27 simons
- * ScanNextFil's buffers must be static, since the other routine accesses
- * them.
- *
- * Revision 0.2 1993/12/04 21:52:40 simons
- * The routines are working. ScanNextFile() buffers one the file currently
- * locked and returns the previous one, so can I change the filename
- * returned by the routine without losing the flow.
- *
- * Revision 0.1 1993/12/04 20:45:42 simons
- * System dependant routines! Will need some work to port them.
- */
-
-
- /************************************* includes ***********/
- #include <stdlib.h>
- #include <string.h>
- #include <dos.h>
-
- /************************************* defines ************/
-
- /************************************* prototypes *********/
-
- /************************************* global variables ***/
- static const char __RCSId[] = "$Id: ScanDir.c,v 0.4 1993/12/08 17:08:46 simons Exp simons $";
-
- static char *flnarray, *flnarray_current;
- static int flnarray_size = 2048;
-
- extern int _OSERR;
-
- /************************************* subroutines ********/
- int InitDirScan(char *flnpattern)
- {
- while (flnarray = malloc(flnarray_size)) {
- if (getfnl(flnpattern,flnarray,flnarray_size,0) != -1) {
- flnarray_current = flnarray;
- return 1;
- }
- else {
- if (_OSERR)
- return 0;
- else {
- free(flnarray);
- flnarray_size += 1024;
- }
- }
- }
- return 0;
- }
-
-
- char *ScanNextFile(void)
- {
- char *name;
-
- if (!(*flnarray_current))
- return NULL;
-
- name = flnarray_current;
- while (*(flnarray_current++))
- ;
-
- return name;
- }
-
-
- void EndDirScan(void)
- {
- free(flnarray);
- flnarray_size = 4096;
- }
-
- @
-
-
- 0.4
- log
- @AmigaOS's filesystem used to have a bug in versions earlier than 40.x,
- that may cause corrupted blocks and even crashes if files are deleted
- or renamed while the ExNext()-scan is in progress. Therefore I changed
- the directory scan. Now, the directory is read completly and all names
- buffered.
- Thanks to Frank Bergknecht <frank@@dino.dinoco.de> for drawing my
- attention to this.
- @
- text
- @d3 2
- a4 2
- * $Revision: 0.3 $
- * $Date: 1993/12/04 21:55:27 $
- d22 1
- a22 1
- * $Id: ScanDir.c,v 0.3 1993/12/04 21:55:27 simons Exp simons $
- d26 9
- d59 1
- a59 1
- static const char __RCSId[] = "$Id: ScanDir.c,v 0.3 1993/12/04 21:55:27 simons Exp simons $";
- d62 1
- a62 1
- static int flnarray_size = 4096;
- d69 8
- a76 6
- if (flnarray = malloc(flnarray_size)) {
- do {
- if (getfnl(flnpattern,flnarray,flnarray_size,0) != -1) {
- flnarray_current = flnarray;
- return 1;
- }
- d78 2
- a79 6
- if (_OSERR)
- return 0;
- else {
- free(flnarray);
- flnarray_size += 1024;
- }
- d81 1
- a81 1
- } while (1);
- @
-
-
- 0.3
- log
- @ScanNextFil's buffers must be static, since the other routine accesses
- them.
- @
- text
- @d3 2
- a4 2
- * $Revision: 0.2 $
- * $Date: 1993/12/04 21:52:40 $
- d22 1
- a22 1
- * $Id: ScanDir.c,v 0.2 1993/12/04 21:52:40 simons Exp simons $
- d26 4
- a36 1
- *
- d41 1
- d43 1
- a43 3
-
- #include <dos/dos.h>
- #include <proto/dos.h>
- d50 1
- a50 1
- static const char __RCSId[] = "$Id: ScanDir.c,v 0.2 1993/12/04 21:52:40 simons Exp simons $";
- d52 2
- a53 4
- BPTR lock = 0;
- struct FileInfoBlock fib;
- char token[64];
- int first_time = 0;
- d55 2
- d58 1
- a58 1
- int InitDirScan(char *dirname, char *pattern)
- d60 5
- a64 6
- int success = 0;
- if (lock = Lock(dirname, ACCESS_READ)) {
- if (Examine(lock, &fib)) {
- if (ParsePatternNoCase(pattern, token, 64) == 1) {
- success = 1;
- first_time = 1;
- d66 9
- a74 1
- }
- d76 1
- a76 2
-
- return success;
- d82 1
- a82 1
- static char scannedname[108], filename[108], filename2[108];
- d84 2
- a85 11
- if (first_time) {
- do {
- if (ExNext(lock, &fib))
- strcpy(filename, fib.fib_FileName);
- else
- filename[0] = '\0';
-
- } while (filename[0] && !MatchPatternNoCase(token, filename));
- strcpy(scannedname, filename);
- first_time = 0;
- }
- d87 3
- a89 8
- do {
- if (ExNext(lock, &fib))
- strcpy(filename, fib.fib_FileName);
- else
- filename[0] = '\0';
- } while (filename[0] && !MatchPatternNoCase(token, filename));
- strcpy(filename2, scannedname);
- strcpy(scannedname, filename);
- d91 1
- a91 1
- return (filename2[0]) ? filename2 : NULL;
- d97 2
- a98 4
- if (lock) {
- UnLock(lock);
- lock = 0;
- }
- @
-
-
- 0.2
- log
- @The routines are working. ScanNextFile() buffers one the file currently
- locked and returns the previous one, so can I change the filename
- returned by the routine without losing the flow.
- @
- text
- @d3 2
- a4 2
- * $Revision: 0.1 $
- * $Date: 1993/12/04 20:45:42 $
- d22 1
- a22 1
- * $Id: ScanDir.c,v 0.1 1993/12/04 20:45:42 simons Exp simons $
- d26 5
- d48 1
- a48 1
- static const char __RCSId[] = "$Id: ScanDir.c,v 0.1 1993/12/04 20:45:42 simons Exp simons $";
- d74 1
- a74 2
- static char scannedname[108];
- char filename[108], filename2[108];
- @
-
-
- 0.1
- log
- @System dependant routines! Will need some work to port them.
- @
- text
- @d3 2
- a4 2
- * $Revision$
- * $Date$
- d22 1
- a22 1
- * $Id$
- d25 4
- a28 1
- * $Log$
- d33 2
- a35 1
- #include <exec/memory.h>
- a36 1
- #include <proto/exec.h>
- d43 1
- a43 2
- static const char __RCSId[] = "$Id$";
-
- d45 4
- d51 53
- @
-