disable the unrecognized nls and x flags
[AROS-Contrib.git] / FryingPan / DTLib / rISOData.cpp
blob0fa7b9c343e7f3b12d530b621852b01179743a2d
1 /*
2 * FryingPan - Amiga CD/DVD Recording Software (User Interface and supporting Libraries only)
3 * Copyright (C) 2001-2011 Tomasz Wiszkowski Tomasz.Wiszkowski at gmail.com
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation; either version 2.1
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "rISOData.h"
21 #include <libclass/dos.h>
22 #include <libclass/exec.h>
23 #include <libclass/utility.h>
25 #define MKID(a,b,c,d) (((a&255)<<24)|((b&255)<<16)|((c&255)<<8)|(d&255))
26 #define ID_CD00 MKID('C','D','0','0')
29 IFileReader *rISOData::openRead(const char* sFile, EDtError &rc)
31 rISOData *pSkel = 0;
32 if (true == checkFile(sFile, rc))
34 pSkel = new rISOData(sFile, rc);
36 return pSkel;
39 rISOData::rISOData(const char *sName, EDtError &rc)
40 : FileReader(sName, rc)
42 if (rc != DT_OK)
43 return;
45 setBlockSize(2048);
46 setLittleEndian(true); // so it is not touched
47 setType(Data_Mode1);
50 BPTR fh;
51 uint8 *ut = new uint8[4096];
52 int64 sz = 0;
54 fh = DOS->Open((char*)sName, MODE_OLDFILE);
55 // seek to primary vol descriptor + volume space size + MSB data
57 for (int i=0; i<9; i++)
58 DOS->Read(fh, ut, 4096);
60 sz = (ut[84] << 24) | (ut[85] << 16) | (ut[86] << 8) | ut[87];
61 sz = (sz + 15) & ~15;
63 DOS->Close(fh);
64 delete [] ut;
65 setDataSize(sz << 11);
69 bool rISOData::checkFile(const char* sFileName, EDtError &rc)
71 bool ok = true;
72 BPTR fh;
74 rc = DT_UnableToOpenFile;
76 fh = DOS->Open(const_cast<char*>(sFileName), MODE_OLDFILE);
77 if (0 == fh)
78 return false;
80 uint8 *ut = new uint8[4096];
82 for (int i=0; i<9; i++)
84 if (DOS->Read(fh, ut, 4096) < 4096)
85 ok = false;
86 if (!ok)
87 break;
90 if (!ok)
92 rc = DT_FileMalformed;
94 else
96 if (ut[1] != 'C')
97 ok = false;
98 if (ut[2] != 'D')
99 ok = false;
100 if (ut[3] != '0')
101 ok = false;
102 if (ut[4] != '0')
103 ok = false;
104 if (ut[5] != '1')
105 ok = false;
107 if (!ok)
108 rc = DT_InvalidFormat;
111 DOS->Close(fh);
112 delete [] ut;
113 return ok;
116 const char *rISOData::static_getName()
118 return "ISO Disc Image Reader";
121 bool rISOData::static_isAudio()
123 return false;
126 bool rISOData::static_isData()
128 return true;
131 bool rISOData::static_isSession()
133 return false;
136 bool rISOData::isAudio()
138 return static_isAudio();
141 bool rISOData::isData()
143 return static_isData();
146 const char *rISOData::getName()
148 return static_getName();
151 // vim: ts=3 et