diff options
Diffstat (limited to 'lib/cdutils.cpp')
-rw-r--r-- | lib/cdutils.cpp | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/lib/cdutils.cpp b/lib/cdutils.cpp index 821d51a..3ab4982 100644 --- a/lib/cdutils.cpp +++ b/lib/cdutils.cpp @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: cdutils.cpp,v 1.28 2004-05-02 21:04:45 pixel Exp $ */ +/* $Id: cdutils.cpp,v 1.29 2004-05-03 12:55:04 pixel Exp $ */ #include <stdio.h> #include <string.h> @@ -63,6 +63,20 @@ unsigned long cdutils::from_MSF(unsigned long msf, unsigned long start) { return from_MSF(m, s, f, start); } +void cdutils::to_MSF(int sect, unsigned char & m, unsigned char & s, unsigned char & f, unsigned long start) { + sect += start; + f = to_BCD(sect % 75); + sect /= 75; + s = to_BCD(sect % 60); + m = to_BCD(sect / 60); +} + +unsigned long cdutils::to_MSF(int sect, unsigned long start) { + unsigned char m, s, f; + to_MSF(sect, m, s, f, start); + return f | (s << 8) | (m << 16); +} + Handle * cdutils::open_ppf(String ppf, String comment) throw (GeneralException) { int i, l; @@ -255,7 +269,7 @@ void cdutils::read_file(Handle * file, long size, int type, int number) { } } -void cdutils::write_sector(Byte * buffer, int type, int number) { +void cdutils::write_sector(Byte * buffer, int type, int number) throw (GeneralException) { Byte old_sector[2352], new_sector[2352]; if (type == GUESS) { @@ -283,7 +297,7 @@ void cdutils::write_sector(Byte * buffer, int type, int number) { } else if (ppf_file) { write_ppf(old_sector, new_sector, number); } else { - printm(M_ERROR, "No writing method for iso file"); + throw GeneralException("No writing method for iso file"); } } @@ -339,6 +353,29 @@ void cdutils::write_file(Handle * file, long size, int type, int number) { } } +void cdutils::create_sector(int type, int number, bool eof) throw (GeneralException) { + Byte sector[2352]; + if (!f_iso_w) + throw GeneralException("Can't create sector: ISO not in write mode"); + + to_MSF(number, yazedc_o.minute, yazedc_o.second, yazedc_o.frame); + memset(sector, 0, 2352); + if ((type == MODE2_FORM1) || (type == MODE2_FORM2)) { + sector[16] = sector[20] = 0; // File Number + sector[17] = sector[21] = 0; // Channel Number + sector[18] = sector[22] = 8 | (eof ? 129 : 0) | + (type == MODE2_FORM2 ? 32 : 0); + sector[19] = sector[23] = 0; // Coding Info + } + yazedc_o.do_encode_L2(sector, type, 0); + + f_iso_w->seek(2352 * number); + + f_iso_w->write(sector, 2352); + + sector_seek(number); +} + void cdutils::show_head_entry(void) { printm(M_BARE, "Sector Size Date Time Flags Name XA flags\n"); } |