disable the unrecognized nls and x flags
[AROS-Contrib.git] / FryingPan / DTLib / wCUESession.cpp
blobcf3d7b80849437d6f4800246f38e123510d36870
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 "wCUESession.h"
21 #include <Generic/LibrarySpool.h>
22 #include <libclass/dos.h>
23 #include <Optical/IOptItem.h>
25 wCUESession::wCUESession(const char* sFileName, const IOptItem *it, EDtError &rc)
27 fcue = 0;
28 fbin = 0;
29 name = sFileName;
30 sess = it;
32 if (it == NULL)
34 rc = DT_InvalidOperation;
35 return;
38 if (it->getItemType() != Item_Session)
40 rc = DT_InvalidOperation;
41 return;
46 wCUESession::~wCUESession()
48 if (0 != fbin)
49 DOS->Close(fbin);
50 if (0 != fcue)
51 DOS->Close(fcue);
52 fcue = 0;
53 fbin = 0;
57 IFileWriter* wCUESession::openWrite(const char* sFile, const IOptItem *it, EDtError &rc)
59 return new wCUESession(sFile, it, rc);
62 const char* wCUESession::getName()
64 return static_getName();
67 bool wCUESession::writeData(void* pBuff, int pLen)
69 ASSERT(sess != 0);
70 int32 size = pLen * sess->getSectorSize();
72 if (fbin != 0)
73 return (size == DOS->Write(fbin, pBuff, size));
75 return false;
78 bool wCUESession::setUp()
80 String s;
81 int trk = 1;
83 s = name + ".cue";
84 fcue = DOS->Open(s.Data(), MODE_NEWFILE);
86 if (fcue == 0)
87 return false;
89 s = DOS->FilePart(name.Data());
90 s = name + ".bin";
91 fbin = DOS->Open(s.Data(), MODE_NEWFILE);
93 if (fbin == 0)
94 return false;
96 DOS->FPuts(fcue, "REM Cue sheet generated by The Frying Pan\n\n");
97 //FPuts(fcue, "REM CATALOG xxxxxxxxxxx\n");
98 //FPuts(fcue, "REM CDTEXTFILE 'file.cdt'\n");
99 //FPuts(fcue, "REM DISC_ID id\n");
100 //FPuts(fcue, "REM UPC_EAN code\n");
101 //FPuts(fcue, "\n");
103 DOS->FPuts(fcue, "\tFILE \"");
104 DOS->FPuts(fcue, s.Data());
105 DOS->FPuts(fcue, "\" BINARY\n\n");
107 if (sess->hasCDText())
109 DOS->FPuts(fcue, "\tARRANGER \"");
110 DOS->FPuts(fcue, const_cast<char*>(sess->getCDTDirector()));
111 DOS->FPuts(fcue, "\"\n\tCOMPOSER \"");
112 DOS->FPuts(fcue, const_cast<char*>(sess->getCDTComposer()));
113 DOS->FPuts(fcue, "\"\n\tMESSAGE \"");
114 DOS->FPuts(fcue, const_cast<char*>(sess->getCDTMessage()));
115 DOS->FPuts(fcue, "\"\n\tPERFORMER \"");
116 DOS->FPuts(fcue, const_cast<char*>(sess->getCDTArtist()));
117 DOS->FPuts(fcue, "\"\n\tSONGWRITER \"");
118 DOS->FPuts(fcue, const_cast<char*>(sess->getCDTLyrics()));
119 DOS->FPuts(fcue, "\"\n\tTITLE \"");
120 DOS->FPuts(fcue, const_cast<char*>(sess->getCDTTitle()));
121 DOS->FPuts(fcue, "\"\n");
122 //FPuts(fcue, "\tREM TOC_INFO t1");
123 //FPuts(fcue, "\n\tREM TOC_INFO2 t2");
124 //FPuts(fcue, "\n\tREM SIZE_INFO");
127 trk = 0;
128 for (int i=0; i<sess->getChildCount(); i++)
130 const IOptItem *it = sess->getChild(i);
132 String f;
133 f.FormatStr("\n\nTRACK %ld %s\n", ARRAY(it->getItemNumber(),
134 it->getDataType() == Data_Audio ? (IPTR)"AUDIO" :
135 it->getDataType() == Data_Mode1 ? (IPTR)"MODE1/2352" : (IPTR)"MODE2/2352"));
137 DOS->FPuts(fcue, f.Data());
139 for (int ix=0; ix<it->getChildCount(); ix++)
141 const IOptItem *idx = it->getChild(ix);
143 f.FormatStr("\tINDEX %ld %ld:%02ld:%02ld\n", ARRAY(
144 idx->getItemNumber(), // NOTE:
145 (IPTR)(idx->getStartAddress()) / 75 / 60, // this is an offset within actual file!
146 (IPTR)(idx->getStartAddress()) / 75 % 60, // and since we create one large file
147 (IPTR)(idx->getStartAddress()) % 75)); // this is the real offset :]
148 DOS->FPuts(fcue, f.Data());
151 //FPuts(fcue, "\tREM FLAGS PRE DCP 4CH SCMS\n");
152 //FPuts(fcue, "\tREM ISRC ccooooyysssss\n");
153 f.FormatStr("\tPREGAP %ld\n", ARRAY(it->getPreGapSize()));
154 DOS->FPuts(fcue, f.Data());
155 //FPuts(fcue, "\tREM POSTGAP yyy\n");
156 //FPuts(fcue, "\tREM GENRE zzz\n");
157 if (it->hasCDText())
159 DOS->FPuts(fcue, "\tARRANGER \"");
160 DOS->FPuts(fcue, const_cast<char*>(it->getCDTDirector()));
161 DOS->FPuts(fcue, "\"\n\tCOMPOSER \"");
162 DOS->FPuts(fcue, const_cast<char*>(it->getCDTComposer()));
163 DOS->FPuts(fcue, "\"\n\tMESSAGE \"");
164 DOS->FPuts(fcue, const_cast<char*>(it->getCDTMessage()));
165 DOS->FPuts(fcue, "\"\n\tPERFORMER \"");
166 DOS->FPuts(fcue, const_cast<char*>(it->getCDTArtist()));
167 DOS->FPuts(fcue, "\"\n\tSONGWRITER \"");
168 DOS->FPuts(fcue, const_cast<char*>(it->getCDTLyrics()));
169 DOS->FPuts(fcue, "\"\n\tTITLE \"");
170 DOS->FPuts(fcue, const_cast<char*>(it->getCDTTitle()));
171 DOS->FPuts(fcue, "\"\n");
172 //FPuts(fcue, "\tREM TOC_INFO t1");
173 //FPuts(fcue, "\n\tREM TOC_INFO2 t2");
174 //FPuts(fcue, "\n\tREM SIZE_INFO");
176 ++trk;
178 return true;
181 void wCUESession::cleanUp()
183 if (fcue != 0)
184 DOS->Close(fcue);
185 if (fbin != 0)
186 DOS->Close(fbin);
187 fcue = 0;
188 fbin = 0;
191 void wCUESession::deleteFiles()
195 void wCUESession::dispose()
197 delete this;
200 void wCUESession::setBlockCount(unsigned long)
204 void wCUESession::setBlockSize(unsigned short)
208 const char *wCUESession::static_getName()
210 return "CUE Sheet Session";
213 bool wCUESession::static_isAudio()
215 return false;
218 bool wCUESession::static_isData()
220 return false;
223 bool wCUESession::static_isSession()
225 return true;