pfssearchfile.c
1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**************************************************************************
* *
* Copyright (C) 1995, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/
#include "osint.h"
#include "controller.h"
s32
osPfsFindFile(OSPfs *pfs, u16 company_code, u32 game_code,
u8 *game_name, u8 *ext_name, s32 *file_no)
{
s32 j;
int i;
__OSDir dir;
s32 ret = 0;
int fail;
if (!(pfs->status & PFS_INITIALIZED))
return(PFS_ERR_INVALID);
if ((ret=__osCheckId(pfs)) != 0){
return(ret);
}
for (j = 0; j < (s32)pfs->dir_size; j++) {
if ((ret = __osContRamRead(pfs->queue, pfs->channel,
(u16)(pfs->dir_table + (int)j), (u8 *)&dir)) != 0)
return(ret);
if ((ret = __osPfsGetStatus(pfs->queue, pfs->channel)) != 0){
return(ret);
}
if ((dir.company_code == company_code) &&
(dir.game_code == game_code)) {
fail = 0;
if (game_name != 0) {
for(i = 0 ; i < PFS_FILE_NAME_LEN ; i++)
if (dir.game_name[i] != game_name[i]) {
fail = 1;
break;
}
}
if ((ext_name != 0) && (fail == 0)){
for(i = 0 ; i < PFS_FILE_EXT_LEN ; i++)
if (dir.ext_name[i] != ext_name[i]){
fail = 1;
break;
}
}
if (fail == 0) {
*file_no = j;
return(ret);
}
}
}
*file_no = -1;
return(PFS_ERR_INVALID); /* file not found */
}