Debian Codegraph @

terps/tads/tads3/resload.h

raw symbols SCIP
1 /* $Header: d:/cvsroot/tads/tads3/resload.h,v 1.2 1999/05/17 02:52:29 MJRoberts Exp $ */
2
3 /*
4 * Copyright (c) 1998, 2002 Michael J. Roberts. All Rights Reserved.
5 *
6 * Please see the accompanying license file, LICENSE.TXT, for information
7 * on using and copying this software.
8 */
9 /*
10 Name
11 resload.h - resource loader
12 Function
13
14 Notes
15
16 Modified
17 10/17/98 MJRoberts - Creation
18 */
19
20 #ifndef RESLOAD_H
21 #define RESLOAD_H
22
23 #include "t3std.h"
24
25 /* ------------------------------------------------------------------------ */
26 /*
27 * Resource loader.
28 */
29
30 class CResLoader
31 {
32 public:
33 /* create the loader */
34 CResLoader();
35
36 /*
37 * create the loader with a root directory - we'll look for external
38 * files under this directory
39 */
40 CResLoader(const char *root_dir);
41
42 /* set the executable file name */
43 void set_exe_filename(const char *exe_filename)
44 {
45 /* discard the old executable filename, if there is one */
46 lib_free_str(exe_filename_);
47
48 /* remember the new path */
49 exe_filename_ = lib_copy_str(exe_filename);
50 }
51
52 /* delete */
53 ~CResLoader();
54
55 /*
56 * Load a resource given a resource path.
57 *
58 * We'll start by looking for a file in the local file system matching
59 * the name 'respath'. We interpret 'respath' as a relative URL; we'll
60 * convert it to local system conventions before looking for the local
61 * file. The path is relative to the root resource directory, which is
62 * the directory specified when the resource loader was created.
63 *
64 * If we fail to find a local file matching the given name, we'll look
65 * for a T3 resource library file with name 'deflib', if that argument
66 * is non-null. 'deflib' is given as a URL to a file relative to the
67 * root resource directory, and should be specified WITHOUT the default
68 * ".t3r" suffix - we'll add that automatically using the appropriate
69 * local filename conventions. If we can find this resource library,
70 * we'll look for 'respath' within the library. Note that 'deflib' is
71 * given in URL notation - we'll convert this to local path conventions
72 * before attempting to locate the file.
73 *
74 * If we still can't find the file, and 'exerestype' is non-null, we'll
75 * look in the executable file for a resource of the given type (this
76 * should be a four-byte identifier, as used with MAKETRX). This
77 * allows resources of different types to be bundled into the
78 * executable file. Note that resources bundled into the executable
79 * must use the standard T3 resource-image file format.
80 */
81 osfildef *open_res_file(const char *respath,
82 const char *deflib,
83 const char *exerestype);
84
85 protected:
86 /*
87 * Load a resource from the executable file. If we find the resource,
88 * returns a file handle with its seek position set to the start of
89 * the resource data. If we can't find the resource in the
90 * executable, returns null.
91 */
92 osfildef *open_exe_res(const char *respath, const char *restype);
93
94 /*
95 * Load a resource from a resource library. If we find the resource,
96 * returns a file handle with its seek position set to the start of the
97 * resource data. If we can't find the library or we can't find the
98 * resource in the library, returns null.
99 */
100 osfildef *open_lib_res(const char *libfile, const char *respath);
101
102 /* root directory for external file searches */
103 char *root_dir_;
104
105 /* path to executable file */
106 char *exe_filename_;
107 };
108
109 #endif /* RESLOAD_H */
110