]> icculus.org git repositories - btb/d2x.git/blob - arch/dos_findfile.c
Fixed build system, minor fixes
[btb/d2x.git] / arch / dos_findfile.c
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14 /*
15  * $Source: /cvs/cvsroot/d2x/arch/dos_findfile.c,v $
16  * $Revision: 1.2 $
17  * $Author: bradleyb $
18  * $Date: 2001-01-29 13:35:08 $
19  *
20  * Dos findfile functions
21  *
22  * $Log: not supported by cvs2svn $
23  */
24
25 #ifdef HAVE_CONFIG_H
26 #include <conf.h>
27 #endif
28
29 #include <dos.h>
30 #include <string.h>
31
32 #include "findfile.h"
33
34
35 //      Global Variables        ----------------------------------------------------------
36
37 static int                              _FileFindFlag = 0;
38 static struct find_t _FileFindStruct;
39
40
41
42 //      Functions
43
44 int     FileFindFirst(char *search_str, FILEFINDSTRUCT *ffstruct)
45 {
46         unsigned retval;
47         
48         if (_FileFindFlag) return -1;
49         
50         retval = _dos_findfirst(search_str, 0, &_FileFindStruct);
51         if (retval) return (int)retval;
52         else {
53                 ffstruct->size = _FileFindStruct.size;
54                 strcpy(ffstruct->name, _FileFindStruct.name);
55                 _FileFindFlag = 1;
56                 return (int)retval;
57         }
58 }
59
60
61 int     FileFindNext(FILEFINDSTRUCT *ffstruct)
62 {
63         unsigned retval;
64
65         if (!_FileFindFlag) return -1;
66
67         retval = _dos_findnext(&_FileFindStruct);
68         if (retval) return (int)retval;
69         else {
70                 ffstruct->size = _FileFindStruct.size;
71                 strcpy(ffstruct->name, _FileFindStruct.name);
72                 return (int)retval;
73         }       
74 }
75  
76
77 int     FileFindClose(void)
78 {
79         unsigned retval = 0;
80
81         if (!_FileFindFlag) return -1;
82         
83         if (retval) return (int)retval;
84         else {
85                 _FileFindFlag = 0;
86                 return (int)retval;
87         }
88 }
89
90
91 //returns 0 if no error
92 int GetFileDateTime(int filehandle, FILETIMESTRUCT *ftstruct)
93 {
94         return _dos_getftime(filehandle, &ftstruct->date, &ftstruct->time);
95
96 }
97
98
99 //returns 0 if no error
100 int SetFileDateTime(int filehandle, FILETIMESTRUCT *ftstruct)
101 {
102         return _dos_setftime(filehandle, ftstruct->date, ftstruct->time);
103 }