uriloader/exthandler/mac/nsDecodeAppleFile.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:a17f4a0a1578
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef nsDecodeAppleFile_h__
7 #define nsDecodeAppleFile_h__
8
9 #include "nscore.h"
10 #include "nsCOMPtr.h"
11 #include "nsIFile.h"
12 #include "nsILocalFileMac.h"
13 #include "nsIOutputStream.h"
14
15 /*
16 ** applefile definitions used
17 */
18 #if PRAGMA_STRUCT_ALIGN
19 #pragma options align=mac68k
20 #endif
21
22 #define APPLESINGLE_MAGIC 0x00051600L
23 #define APPLEDOUBLE_MAGIC 0x00051607L
24 #define VERSION 0x00020000
25
26 #define NUM_ENTRIES 6
27
28 #define ENT_DFORK 1L
29 #define ENT_RFORK 2L
30 #define ENT_NAME 3L
31 #define ENT_COMMENT 4L
32 #define ENT_DATES 8L
33 #define ENT_FINFO 9L
34
35 #define CONVERT_TIME 1265437696L
36
37 /*
38 ** data type used in the header decoder.
39 */
40 typedef struct ap_header
41 {
42 int32_t magic;
43 int32_t version;
44 int32_t fill[4];
45 int16_t entriesCount;
46
47 } ap_header;
48
49 typedef struct ap_entry
50 {
51 int32_t id;
52 int32_t offset;
53 int32_t length;
54
55 } ap_entry;
56
57 typedef struct ap_dates
58 {
59 int32_t create, modify, backup, access;
60
61 } ap_dates;
62
63 #if PRAGMA_STRUCT_ALIGN
64 #pragma options align=reset
65 #endif
66
67 /*
68 **Error codes
69 */
70 enum {
71 errADNotEnoughData = -12099,
72 errADNotSupported,
73 errADBadVersion
74 };
75
76
77 class nsDecodeAppleFile : public nsIOutputStream
78 {
79 public:
80 NS_DECL_THREADSAFE_ISUPPORTS
81 NS_DECL_NSIOUTPUTSTREAM
82
83 nsDecodeAppleFile();
84 virtual ~nsDecodeAppleFile();
85
86 nsresult Initialize(nsIOutputStream *output, nsIFile *file);
87
88 private:
89 #define MAX_BUFFERSIZE 1024
90 enum ParserState {parseHeaders, parseEntries, parseLookupPart, parsePart, parseSkipPart,
91 parseDataFork, parseResourceFork, parseWriteThrough};
92
93 nsCOMPtr<nsIOutputStream> m_output;
94 FSSpec m_fsFileSpec;
95 SInt16 m_rfRefNum;
96
97 unsigned char * m_dataBuffer;
98 int32_t m_dataBufferLength;
99 ParserState m_state;
100 ap_header m_headers;
101 ap_entry * m_entries;
102 int32_t m_offset;
103 int32_t m_dataForkOffset;
104 int32_t m_totalDataForkWritten;
105 int32_t m_totalResourceForkWritten;
106 bool m_headerOk;
107
108 int32_t m_currentPartID;
109 int32_t m_currentPartLength;
110 int32_t m_currentPartCount;
111
112 Str255 m_comment;
113 ap_dates m_dates;
114 FInfo m_finderInfo;
115 FXInfo m_finderExtraInfo;
116 };
117
118 #endif

mercurial