1 |
|
---|
2 | #ifndef _ROM_FILEPANEL_H_
|
---|
3 | #define _ROM_FILEPANEL_H_
|
---|
4 |
|
---|
5 | #include <View.h>
|
---|
6 | #include <Window.h>
|
---|
7 | #include <FilePanel.h>
|
---|
8 | #include <Entry.h>
|
---|
9 | #include <Path.h>
|
---|
10 | #include <String.h>
|
---|
11 |
|
---|
12 | #include <iostream>
|
---|
13 |
|
---|
14 | class ROMFilePanel : public BFilePanel
|
---|
15 | {
|
---|
16 | public:
|
---|
17 | ROMFilePanel();
|
---|
18 | virtual ~ROMFilePanel();
|
---|
19 |
|
---|
20 | private:
|
---|
21 | virtual void SelectionChanged (void);
|
---|
22 |
|
---|
23 | private:
|
---|
24 | void Customize (void);
|
---|
25 |
|
---|
26 | private:
|
---|
27 | entry_ref fPrevRef;
|
---|
28 | };
|
---|
29 |
|
---|
30 |
|
---|
31 | class ROMFilter : public BRefFilter
|
---|
32 | {
|
---|
33 | public:
|
---|
34 | virtual bool Filter (const entry_ref *ref, BNode *node, struct stat_beos *st,
|
---|
35 | const char *filetype)
|
---|
36 | {
|
---|
37 | (void)node;
|
---|
38 | (void)st;
|
---|
39 |
|
---|
40 | BString tempFileName (ref->name);
|
---|
41 | BString tempFileType (filetype);
|
---|
42 | int32 pos;
|
---|
43 |
|
---|
44 | std::cout << tempFileName << std::endl;
|
---|
45 |
|
---|
46 |
|
---|
47 | // first check the file type.
|
---|
48 | // we don't want to filter out directories, symlinks, or volumes.
|
---|
49 |
|
---|
50 | if (tempFileType.ICompare ("application/x-vnd.Be-directory") == 0 ||
|
---|
51 | tempFileType.ICompare ("application/x-vnd.Be-volume") == 0 ||
|
---|
52 | tempFileType.ICompare ("application/x-vnd.Be.symlink") == 0) {
|
---|
53 | return true;
|
---|
54 | }
|
---|
55 |
|
---|
56 | // otherwise, we'll go ahead, analyse the file's extension
|
---|
57 | // and determine what to do from there.
|
---|
58 |
|
---|
59 | pos = tempFileName.FindLast ('.');
|
---|
60 | if (pos == B_ERROR) {
|
---|
61 | return false;
|
---|
62 | }
|
---|
63 |
|
---|
64 | tempFileName.Remove (0, ++pos);
|
---|
65 | if (tempFileName.ICompare ("nes") == 0 || // iNES format
|
---|
66 | tempFileName.ICompare ("unf") == 0 || // UNIF archive (DOS)
|
---|
67 | tempFileName.ICompare ("unif") == 0 || // UNIF archive (UNIX)
|
---|
68 | tempFileName.ICompare ("fds") == 0) { // FDS format
|
---|
69 | return true;
|
---|
70 | }
|
---|
71 |
|
---|
72 | // we couldn't catch anything.
|
---|
73 | return false;
|
---|
74 | }
|
---|
75 | };
|
---|
76 |
|
---|
77 | #endif // _ROM_FILEPANEL_H_
|
---|
78 |
|
---|
79 |
|
---|