FireBirdLib - Topfield TMS PVR TAP Programming Library
INILocateFile.c
Go to the documentation of this file.
1#include <string.h>
2#include "libFireBird.h"
3
4//Attention: this function will stay in the directory where it has found the file
5//It is up to the caller to use HDD_TAP_PushDir() and HDD_TAP_PopDir()
6
7INILOCATION INILocateFile(char *FileName, char *AppName)
8{
10
12 char dir[200] = "";
13
14 if(FileName)
15 {
16 //Current directory?
17 if(TAP_Hdd_Exist(FileName)) location = INILOCATION_AtCurrentDir;
18 //Else search (which automatically activates tapapifix)
19 else
20 {
22
23 if(HDD_ChangeDir("/ProgramFiles"))
24 {
25 //Try /ProgramFiles
26 if(TAP_Hdd_Exist(FileName))
27 {
29 strcpy(dir, "/ProgramFiles");
30 }
31
32 if(HDD_ChangeDir("Settings"))
33 {
34 //Try /ProgramFiles/Settings
35 if(TAP_Hdd_Exist(FileName))
36 {
37 location = INILOCATION_AtSettings;
38 strcpy(dir, "/ProgramFiles/Settings");
39 }
40
41 //Try /ProgramFiles/Settings/<AppName>
42 if(AppName && *AppName && (*AppName != '/') && HDD_ChangeDir(AppName) && TAP_Hdd_Exist(FileName))
43 {
44 location = INILOCATION_AtAppName;
45 dir[0] = '\0';
46 }
47 }
48 }
49 }
50 }
51
52 //Restore the directory where the file has been found
53 if(*dir) HDD_ChangeDir(dir);
54
55 TRACEEXIT();
56 return location;
57}
bool HDD_ChangeDir(const char *Dir)
Definition: HDD_ChangeDir.c:5
INILOCATION INILocateFile(char *FileName, char *AppName)
Definition: INILocateFile.c:7
int HDD_TAP_GetCurrentDir(char *CurrentDir)
#define TRACEEXIT()
Definition: libFireBird.h:1244
INILOCATION
Definition: libFireBird.h:2000
@ INILOCATION_AtSettings
Definition: libFireBird.h:2005
@ INILOCATION_AtAppName
Definition: libFireBird.h:2004
@ INILOCATION_AtCurrentDir
Definition: libFireBird.h:2003
@ INILOCATION_AtProgramFiles
Definition: libFireBird.h:2006
@ INILOCATION_NotFound
Definition: libFireBird.h:2001
#define TRACEENTER()
Definition: libFireBird.h:1243