1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "DirectoryImporter.h"
24 #include "FileStream.h"
25 #include "Interface.h"
26 #include "ResourceDesc.h"
32 DirectoryImporter::DirectoryImporter(void)
36 DirectoryImporter::~DirectoryImporter(void)
40 bool DirectoryImporter::Open(const char *dir
, const char *desc
)
47 static bool FindIn(const char *Path
, const char *ResRef
, const char *Type
)
49 char p
[_MAX_PATH
], f
[_MAX_PATH
] = {0};
54 return PathJoin(p
, Path
, f
, NULL
);
57 static FileStream
*SearchIn(const char * Path
,const char * ResRef
, const char *Type
)
59 char p
[_MAX_PATH
], f
[_MAX_PATH
] = {0};
64 if (!PathJoin(p
, Path
, f
, NULL
))
67 FileStream
* fs
= new FileStream();
69 if(!fs
->Open(p
, true)) {
76 bool DirectoryImporter::HasResource(const char* resname
, SClass_ID type
)
78 return FindIn( path
, resname
, core
->TypeExt(type
) );
81 bool DirectoryImporter::HasResource(const char* resname
, const ResourceDesc
&type
)
83 return FindIn( path
, resname
, type
.GetExt() );
86 DataStream
* DirectoryImporter::GetResource(const char* resname
, SClass_ID type
)
88 return SearchIn( path
, resname
, core
->TypeExt(type
) );
91 DataStream
* DirectoryImporter::GetResource(const char* resname
, const ResourceDesc
&type
)
93 return SearchIn( path
, resname
, type
.GetExt() );
96 #include "plugindef.h"
98 GEMRB_PLUGIN(0xAB4534, "Directory Importer")
99 PLUGIN_CLASS(PLUGIN_RESOURCE_DIRECTORY
, DirectoryImporter
)