diff --git a/Cache/BlockCache.cpp b/Cache/BlockCache.cpp index 3c24d2a..7811e20 100644 --- a/Cache/BlockCache.cpp +++ b/Cache/BlockCache.cpp @@ -11,16 +11,14 @@ #include #include -#include -#include +#include +#include using namespace Device; -using ProFUSE::Exception; -using ProFUSE::POSIXException; BlockCache::BlockCache(BlockDevicePointer device) : diff --git a/Cache/ConcreteBlockCache.cpp b/Cache/ConcreteBlockCache.cpp index ef8c6b1..62a788f 100644 --- a/Cache/ConcreteBlockCache.cpp +++ b/Cache/ConcreteBlockCache.cpp @@ -10,8 +10,8 @@ #include #include -#include -#include +#include +#include /* @@ -51,8 +51,6 @@ using namespace Device; -using ProFUSE::Exception; -using ProFUSE::POSIXException; //typedef std::vector::iterator EntryIter; diff --git a/Cache/MappedBlockCache.cpp b/Cache/MappedBlockCache.cpp index bf0892b..973fb05 100644 --- a/Cache/MappedBlockCache.cpp +++ b/Cache/MappedBlockCache.cpp @@ -10,14 +10,12 @@ #include #include -#include - +#include +#include using namespace Device; -using ProFUSE::Exception; -using ProFUSE::POSIXException; BlockCachePointer MappedBlockCache::Create(BlockDevicePointer device, void *data) { @@ -124,12 +122,12 @@ void MappedBlockCache::sync(unsigned block) end = (void *)((ptrdiff_t)end / pagesize * pagesize); if (::msync(start, pagesize, MS_SYNC) != 0) - throw POSIXException(__METHOD__ ": msync", errno); + throw POSIX::Exception(__METHOD__ ": msync", errno); if (start != end) { if (::msync(end, pagesize, MS_SYNC) != 0) - throw POSIXException(__METHOD__ ": msync", errno); + throw POSIX::Exception(__METHOD__ ": msync", errno); } } diff --git a/Device/Adaptor.cpp b/Device/Adaptor.cpp index 7410611..7b99083 100644 --- a/Device/Adaptor.cpp +++ b/Device/Adaptor.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include using namespace Device; @@ -142,7 +142,7 @@ uint8_t NibbleAdaptor::encode62(uint8_t val) }; if (val > 0x3f) - throw ProFUSE::Exception(__METHOD__ ": Invalid 6-2 value."); + throw ::Exception(__METHOD__ ": Invalid 6-2 value."); return table[val]; } @@ -165,7 +165,7 @@ uint8_t NibbleAdaptor::decode62(uint8_t val) }; if ((val < 0x90) || (table[val - 0x90] == 0xff)) - throw ProFUSE::Exception(__METHOD__ ": Invalid 6-2 encoding."); + throw ::Exception(__METHOD__ ": Invalid 6-2 encoding."); return table[val - 0x90]; } @@ -238,10 +238,10 @@ NibbleAdaptor::NibbleAdaptor(void *address, unsigned length) checksum = decode44(buffer[offset + 9], buffer[offset + 10]); if (volume ^ track ^ sector ^ checksum) - throw ProFUSE::Exception(__METHOD__ ": Invalid address checksum."); + throw ::Exception(__METHOD__ ": Invalid address checksum."); if (track > 35 || sector > 16) - throw ProFUSE::Exception(__METHOD__ ": Invalid track/sector."); + throw ::Exception(__METHOD__ ": Invalid track/sector."); offset += 3 + 8 + 3; @@ -294,7 +294,7 @@ NibbleAdaptor::NibbleAdaptor(void *address, unsigned length) { int offset = distance(_index.begin(), iter); std::fprintf(stderr, "Error: track %u sector %u missing.\n", offset / 16, offset % 16); - //throw ProFUSE::Exception(__METHOD__ ": Sector missing."); + //throw ::Exception(__METHOD__ ": Sector missing."); } } @@ -361,7 +361,7 @@ void NibbleAdaptor::readTrackSector(TrackSector ts, void *bp) #define __METHOD__ "NibbleAdaptor::readTrackSector" if (ts.track > 35 || ts.sector > 16) - throw ProFUSE::Exception(__METHOD__ ": Invalid track/sector."); + throw ::Exception(__METHOD__ ": Invalid track/sector."); CircleBuffer buffer(_address, _length); @@ -374,7 +374,7 @@ void NibbleAdaptor::readTrackSector(TrackSector ts, void *bp) if (offset == -1) { - throw ProFUSE::Exception(__METHOD__ ": Missing track/sector."); + throw ::Exception(__METHOD__ ": Missing track/sector."); } // first 86 bytes are in the auxbuffer, backwards. @@ -418,7 +418,7 @@ void NibbleAdaptor::readTrackSector(TrackSector ts, void *bp) if (checksum != decode62(buffer[index++])) std::fprintf(stderr, "Invalid checksum on track %u, sector %u\n", ts.track, ts.sector); - //throw ProFUSE::Exception(__METHOD__ ": Invalid field checksum."); + //throw ::Exception(__METHOD__ ": Invalid field checksum."); } @@ -428,7 +428,7 @@ void NibbleAdaptor::writeTrackSector(TrackSector ts, const void *bp) #define __METHOD__ "NibbleAdaptor::writeTrackSector" if (ts.track > 35 || ts.sector > 16) - throw ProFUSE::Exception(__METHOD__ ": Invalid track/sector."); + throw ::Exception(__METHOD__ ": Invalid track/sector."); uint8_t auxBuffer[86]; uint8_t checksum = 0; diff --git a/Device/BlockDevice.cpp b/Device/BlockDevice.cpp index 6ac1d9e..15becd0 100644 --- a/Device/BlockDevice.cpp +++ b/Device/BlockDevice.cpp @@ -12,7 +12,8 @@ #include #include -#include +#include +#include #include #include @@ -26,8 +27,6 @@ using namespace Device; -using ProFUSE::Exception; -using ProFUSE::POSIXException; unsigned BlockDevice::ImageType(MappedFile *f, unsigned defv) @@ -124,7 +123,7 @@ BlockDevicePointer BlockDevice::Open(const char *name, File::FileFlags flags, un if (::stat(name, &st) != 0) { - throw POSIXException(__METHOD__ ": stat error", errno); + throw POSIX::Exception(__METHOD__ ": stat error", errno); } // /dev/xxx ignore the type. diff --git a/Device/BlockDevice.h b/Device/BlockDevice.h index 4b31e71..2f23f8a 100644 --- a/Device/BlockDevice.h +++ b/Device/BlockDevice.h @@ -7,8 +7,8 @@ #include #include -#include -#include +#include +#include #include diff --git a/Device/DavexDiskImage.cpp b/Device/DavexDiskImage.cpp index f9e44ab..ea2b813 100644 --- a/Device/DavexDiskImage.cpp +++ b/Device/DavexDiskImage.cpp @@ -19,8 +19,6 @@ using namespace Device; using namespace LittleEndian; -using ProFUSE::Exception; -using ProFUSE::POSIXException; /* http://www.umich.edu/~archive/apple2/technotes/ftn/FTN.E0.8004 @@ -86,7 +84,7 @@ bool DavexDiskImage::Validate(MappedFile *f) if (!Validate(f, std::nothrow)) - throw Exception(__METHOD__ ": Invalid file format."); + throw ::Exception(__METHOD__ ": Invalid file format."); return true; } diff --git a/Device/Device.h b/Device/Device.h index 458320c..efb49db 100644 --- a/Device/Device.h +++ b/Device/Device.h @@ -9,7 +9,7 @@ #ifndef __DEVICE_DEVICE_H__ #define __DEVICE_DEVICE_H__ -#include +#include namespace Device { diff --git a/Device/DiskCopy42Image.cpp b/Device/DiskCopy42Image.cpp index 9498720..1665a54 100644 --- a/Device/DiskCopy42Image.cpp +++ b/Device/DiskCopy42Image.cpp @@ -16,9 +16,6 @@ using namespace Device; using namespace BigEndian; -using ProFUSE::Exception; -using ProFUSE::POSIXException; - enum { @@ -221,7 +218,7 @@ bool DiskCopy42Image::Validate(MappedFile *file) if (!Validate(file, std::nothrow)) - throw Exception(__METHOD__ ": Invalid file format."); + throw ::Exception(__METHOD__ ": Invalid file format."); return true; } diff --git a/Device/DiskImage.cpp b/Device/DiskImage.cpp index a1c15b9..4eae7b7 100644 --- a/Device/DiskImage.cpp +++ b/Device/DiskImage.cpp @@ -14,13 +14,11 @@ #include -#include +#include using namespace Device; -using ProFUSE::Exception; -using ProFUSE::POSIXException; /* @@ -74,7 +72,7 @@ void DiskImage::read(unsigned block, void *bp) #define __METHOD__ "DiskImage::read" if (block >= _blocks) - throw Exception(__METHOD__ ": Invalid block."); + throw ::Exception(__METHOD__ ": Invalid block."); _adaptor->readBlock(block, bp); } @@ -85,7 +83,7 @@ void DiskImage::write(unsigned block, const void *bp) #define __METHOD__ "DiskImage::write" if (block >= _blocks) - throw Exception(__METHOD__ ": Invalid block."); + throw ::Exception(__METHOD__ ": Invalid block."); _adaptor->writeBlock(block, bp); } @@ -97,7 +95,7 @@ void DiskImage::sync() if (_file.isValid()) return _file.sync(); - throw Exception(__METHOD__ ": File not set."); + throw ::Exception(__METHOD__ ": File not set."); } @@ -147,10 +145,10 @@ bool ProDOSOrderDiskImage::Validate(MappedFile *f) #undef __METHOD__ #define __METHOD__ "ProDOSOrderDiskImage::Validate" - if (!f || !f->isValid()) throw Exception(__METHOD__ ": File not set."); + if (!f || !f->isValid()) throw ::Exception(__METHOD__ ": File not set."); if (!Validate(f, std::nothrow)) - throw Exception(__METHOD__ ": Invalid file format."); + throw ::Exception(__METHOD__ ": Invalid file format."); return true; } @@ -218,11 +216,11 @@ bool DOSOrderDiskImage::Validate(MappedFile *f) #undef __METHOD__ #define __METHOD__ "DOSOrderDiskImage::Validate" - if (!f || !f->isValid()) throw Exception(__METHOD__ ": File not set."); + if (!f || !f->isValid()) throw ::Exception(__METHOD__ ": File not set."); if (!Validate(f, std::nothrow)) - throw Exception(__METHOD__ ": Invalid file format."); + throw ::Exception(__METHOD__ ": Invalid file format."); return true; } diff --git a/Device/DiskImage.h b/Device/DiskImage.h index 25a5c39..8a1b786 100644 --- a/Device/DiskImage.h +++ b/Device/DiskImage.h @@ -4,8 +4,6 @@ #include #include -#include - #include #include diff --git a/Device/RawDevice.cpp b/Device/RawDevice.cpp index 96f10b3..0cf846d 100644 --- a/Device/RawDevice.cpp +++ b/Device/RawDevice.cpp @@ -31,12 +31,11 @@ #include -#include +#include +#include using namespace Device; -using ProFUSE::Exception; -using ProFUSE::POSIXException; #ifdef __SUN__ void RawDevice::devSize(int fd) @@ -47,7 +46,7 @@ void RawDevice::devSize(int fd) struct dk_minfo minfo; if (::ioctl(fd, DKIOCGMEDIAINFO, &minfo) < 0) - throw POSIXException(__METHOD__ ": Unable to determine device size.", errno); + throw POSIX::Exception(__METHOD__ ": Unable to determine device size.", errno); _size = minfo.dki_lbsize * minfo.dki_capacity; _blockSize = 512; // not really, but whatever. @@ -66,11 +65,11 @@ void RawDevice::devSize(int fd) uint64_t blockCount; // 64 bit if (::ioctl(fd, DKIOCGETBLOCKSIZE, &blockSize) < 0) - throw POSIXException(__METHOD__ ": Unable to determine block size.", errno); + throw POSIX::Exception(__METHOD__ ": Unable to determine block size.", errno); if (::ioctl(fd, DKIOCGETBLOCKCOUNT, &blockCount) < 0) - throw POSIXException(__METHOD__ ": Unable to determine block count.", errno); + throw POSIX::Exception(__METHOD__ ": Unable to determine block count.", errno); _blockSize = blockSize; _size = _blockSize * blockCount; @@ -90,7 +89,7 @@ void RawDevice::devSize(int fd) int blocks; if (::ioctl(fd, BLKGETSIZE, &blocks) < 0) - throw POSIXException(__METHOD__ ": Unable to determine device size.", errno); + throw POSIX::Exception(__METHOD__ ": Unable to determine device size.", errno); _size = 512 * blocks; _blockSize = 512; // @@ -113,10 +112,10 @@ void RawDevice::devSize(int fd) off_t mediaSize; if (::ioctl(fd, DIOCGSECTORSIZE, &blockSize) - throw POSIXException(__METHOD__ ": Unable to determine block size.", errno); + throw POSIX::Exception(__METHOD__ ": Unable to determine block size.", errno); if (::ioctl(fd, DIOCGMEDIASIZE, &mediaSize) - throw POSIXException(__METHOD__ ": Unable to determine media size.", errno); + throw POSIX::Exception(__METHOD__ ": Unable to determine media size.", errno); _blockSize = blockSize; _size = mediaSize; @@ -138,7 +137,7 @@ void RawDevice::devSize(int fd) if (::ioctl(fd, DIOCGETP, &entry) < 0) - throw POSIXException(__METHOD__ ": Unable to determine device size.", errno); + throw POSIX::Exception(__METHOD__ ": Unable to determine device size.", errno); _size = entry.size _blockSize = 512; // not really but whatever. @@ -157,7 +156,7 @@ RawDevice::RawDevice(const char *name, File::FileFlags flags) : if (!_file.isValid()) { - throw Exception(__METHOD__ ": Invalid file handle."); + throw ::Exception(__METHOD__ ": Invalid file handle."); } _readOnly = flags == File::ReadOnly; @@ -178,7 +177,7 @@ RawDevice::RawDevice(File& file, File::FileFlags flags) : if (!_file.isValid()) { - throw Exception(__METHOD__ ": Invalid file handle."); + throw ::Exception(__METHOD__ ": Invalid file handle."); } _readOnly = flags == File::ReadOnly; @@ -208,8 +207,8 @@ void RawDevice::read(unsigned block, void *bp) #undef __METHOD__ #define __METHOD__ "RawDevice::read" - if (block >= _blocks) throw Exception(__METHOD__ ": Invalid block number."); - if (bp == 0) throw Exception(__METHOD__ ": Invalid address."); + if (block >= _blocks) throw ::Exception(__METHOD__ ": Invalid block number."); + if (bp == 0) throw ::Exception(__METHOD__ ": Invalid address."); // sun -- use pread // apple - read full native block(s) ? @@ -220,8 +219,8 @@ void RawDevice::read(unsigned block, void *bp) // TODO -- EINTR? if (ok != 512) throw ok < 0 - ? POSIXException(__METHOD__ ": Error reading block.", errno) - : Exception(__METHOD__ ": Error reading block."); + ? POSIX::Exception(__METHOD__ ": Error reading block.", errno) + : ::Exception(__METHOD__ ": Error reading block."); } @@ -231,8 +230,8 @@ void RawDevice::read(TrackSector ts, void *bp) #define __METHOD__ "RawDevice::read" unsigned block = ts.track * 8 + ts.sector / 2; - if (block >= _blocks) throw Exception(__METHOD__ ": Invalid block number."); - if (bp == 0) throw Exception(__METHOD__ ": Invalid address."); + if (block >= _blocks) throw ::Exception(__METHOD__ ": Invalid block number."); + if (bp == 0) throw ::Exception(__METHOD__ ": Invalid address."); // sun -- use pread // apple - read full native block(s) ? @@ -243,8 +242,8 @@ void RawDevice::read(TrackSector ts, void *bp) // TODO -- EINTR? if (ok != 256) throw ok < 0 - ? POSIXException(__METHOD__ ": Error reading block.", errno) - : Exception(__METHOD__ ": Error reading block."); + ? POSIX::Exception(__METHOD__ ": Error reading block.", errno) + : ::Exception(__METHOD__ ": Error reading block."); } @@ -253,10 +252,10 @@ void RawDevice::write(unsigned block, const void *bp) #undef __METHOD__ #define __METHOD__ "RawDevice::write" - if (block > _blocks) throw Exception(__METHOD__ ": Invalid block number."); + if (block > _blocks) throw ::Exception(__METHOD__ ": Invalid block number."); if (_readOnly) - throw Exception(__METHOD__ ": File is readonly."); + throw ::Exception(__METHOD__ ": File is readonly."); off_t offset = block * 512; @@ -264,8 +263,8 @@ void RawDevice::write(unsigned block, const void *bp) if (ok != 512) throw ok < 0 - ? POSIXException(__METHOD__ ": Error writing block.", errno) - : Exception(__METHOD__ ": Error writing block."); + ? POSIX::Exception(__METHOD__ ": Error writing block.", errno) + : ::Exception(__METHOD__ ": Error writing block."); } @@ -275,10 +274,10 @@ void RawDevice::write(TrackSector ts, const void *bp) #define __METHOD__ "RawDevice::write" unsigned block = ts.track * 8 + ts.sector / 2; - if (block > _blocks) throw Exception(__METHOD__ ": Invalid block number."); + if (block > _blocks) throw ::Exception(__METHOD__ ": Invalid block number."); if (_readOnly) - throw Exception(__METHOD__ ": File is readonly."); + throw ::Exception(__METHOD__ ": File is readonly."); off_t offset = (ts.track * 16 + ts.sector) * 256; @@ -286,8 +285,8 @@ void RawDevice::write(TrackSector ts, const void *bp) if (ok != 256) throw ok < 0 - ? POSIXException(__METHOD__ ": Error writing block.", errno) - : Exception(__METHOD__ ": Error writing block."); + ? POSIX::Exception(__METHOD__ ": Error writing block.", errno) + : ::Exception(__METHOD__ ": Error writing block."); } @@ -316,6 +315,6 @@ void RawDevice::sync() if (_readOnly) return; if (::fsync(_file.fd()) < 0) - throw POSIXException(__METHOD__ ": fsync error.", errno); + throw POSIX::Exception(__METHOD__ ": fsync error.", errno); } diff --git a/Device/SDKImage.cpp b/Device/SDKImage.cpp index 3c27530..ab6c662 100644 --- a/Device/SDKImage.cpp +++ b/Device/SDKImage.cpp @@ -20,39 +20,8 @@ #include #include -#include - - -using ProFUSE::Exception; -using ProFUSE::POSIXException; - - -class NuFXException : public Exception -{ -public: - - NuFXException(const char *cp, NuError error); - NuFXException(const std::string& string, NuError error); - - virtual const char *errorString(); - -}; - - -inline NuFXException::NuFXException(const char *cp, NuError error) : -Exception(cp, error) -{ -} - -inline NuFXException::NuFXException(const std::string& string, NuError error) : -Exception(string, error) -{ -} - -const char *NuFXException::errorString() -{ - return ::NuStrError((NuError)error()); -} +#include +#include using namespace Device; diff --git a/Device/UniversalDiskImage.cpp b/Device/UniversalDiskImage.cpp index 18cec76..08f7c4d 100644 --- a/Device/UniversalDiskImage.cpp +++ b/Device/UniversalDiskImage.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include @@ -11,10 +11,6 @@ using namespace Device; using namespace LittleEndian; -using ProFUSE::Exception; -using ProFUSE::POSIXException; - - UniversalDiskImage::UniversalDiskImage(MappedFile *file) : @@ -138,7 +134,7 @@ bool UniversalDiskImage::Validate(MappedFile *file) #define __METHOD__ "UniversalDiskImage::Validate" if (!Validate(file, std::nothrow)) - throw Exception(__METHOD__ ": Invalid file format."); + throw ::Exception(__METHOD__ ": Invalid file format."); return true; } diff --git a/File/File.cpp b/File/File.cpp index 4cc41db..0b9f41e 100644 --- a/File/File.cpp +++ b/File/File.cpp @@ -2,12 +2,8 @@ #include #include -#include - - - -using ProFUSE::Exception; -using ProFUSE::POSIXException; +#include +#include File::File() @@ -49,7 +45,7 @@ File::File(const char *name, int flags) _fd = ::open(name, flags); if (_fd < 0) - throw POSIXException( __METHOD__ ": open", errno); + throw POSIX::Exception( __METHOD__ ": open", errno); } File::File(const char *name, int flags, mode_t mode) @@ -59,7 +55,7 @@ File::File(const char *name, int flags, mode_t mode) _fd = ::open(name, flags, mode); if (_fd < 0) - throw POSIXException( __METHOD__ ": open", errno); + throw POSIX::Exception( __METHOD__ ": open", errno); } @@ -70,7 +66,7 @@ File::File(const char *name, FileFlags flags) _fd = ::open(name, flags == ReadOnly ? O_RDONLY : O_RDWR); if (_fd < 0) - throw POSIXException( __METHOD__ ": open", errno); + throw POSIX::Exception( __METHOD__ ": open", errno); } @@ -99,7 +95,7 @@ void File::close() // destructor shouldn't throw. /* if (::close(fd) != 0) - throw POSIXException(__METHOD__ ": close", errno); + throw POSIX::Exception(__METHOD__ ": close", errno); */ } } diff --git a/File/MappedFile.cpp b/File/MappedFile.cpp index 2b8eb91..5387376 100644 --- a/File/MappedFile.cpp +++ b/File/MappedFile.cpp @@ -4,10 +4,8 @@ #include #include -#include - - -using ProFUSE::POSIXException; +#include +#include MappedFile::MappedFile() { @@ -81,16 +79,16 @@ void MappedFile::init(const File &f, bool readOnly, size_t size) // close enough if (f.fd() < 0) - throw POSIXException( __METHOD__, EBADF); + throw POSIX::Exception( __METHOD__, EBADF); if (!size) { if (::fstat(f.fd(), &st) != 0) - throw POSIXException(__METHOD__ ": fstat", errno); + throw POSIX::Exception(__METHOD__ ": fstat", errno); if (!S_ISREG(st.st_mode)) - throw POSIXException(__METHOD__, ENODEV); + throw POSIX::Exception(__METHOD__, ENODEV); size = st.st_size; } @@ -99,7 +97,7 @@ void MappedFile::init(const File &f, bool readOnly, size_t size) _address = ::mmap(0, _length, prot, flags, f.fd(), 0); if (_address == MAP_FAILED) - throw POSIXException(__METHOD__ ": mmap", errno); + throw POSIX::Exception(__METHOD__ ": mmap", errno); _readOnly = readOnly; } @@ -127,7 +125,7 @@ void MappedFile::close() // destructor shouldn't throw. /* if (::munmap(address, length) != 0) - throw POSIXException(__METHOD__ ": munmap", errno); + throw POSIX::Exception(__METHOD__ ": munmap", errno); */ } } @@ -140,7 +138,7 @@ void MappedFile::sync() if (_address != MAP_FAILED) { if (::msync(_address, _length, MS_SYNC) != 0) - throw POSIXException(__METHOD__ ": msync", errno); + throw POSIX::Exception(__METHOD__ ": msync", errno); } } @@ -173,14 +171,14 @@ MappedFile *MappedFile::Create(const char *name, size_t size) if (!fd.isValid()) { - throw POSIXException(__METHOD__ ": Unable to create file.", errno); + throw POSIX::Exception(__METHOD__ ": Unable to create file.", errno); } // TODO -- is ftruncate portable? if (::ftruncate(fd.fd(), size) < 0) { // TODO -- unlink? - throw POSIXException(__METHOD__ ": Unable to truncate file.", errno); + throw POSIX::Exception(__METHOD__ ": Unable to truncate file.", errno); } return new MappedFile(fd, File::ReadWrite, size); diff --git a/Makefile b/Makefile index 02ebdab..1fb3bbb 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ endif ifdef HAVE_NUFX DEVICE_OBJECTS += Device/SDKImage.o + EXCEPTION_OBJECTS += NuFX/Exception.o LDFLAGS += -L/usr/local/lib/ LIBS += -lnufx -lz CPPFLAGS += -DHAVE_NUFX=1 @@ -24,8 +25,11 @@ OBJECTS += ${wildcard Device/*.o} OBJECTS += ${wildcard Endian/*.o} OBJECTS += ${wildcard File/*.o} OBJECTS += ${wildcard Pascal/*.o} -OBJECTS += ${wildcard ProFUSE/*.o} +OBJECTS += ${wildcard Common/*.o} OBJECTS += ${wildcard ProDOS/*.o} +OBJECTS += ${wildcard POSIX/*.o} +OBJECTS += ${wildcard NuFX/*.o} + TARGETS = o/apfm o/newfs_pascal o/fuse_pascal o/profuse o/xattr @@ -67,13 +71,19 @@ PASCAL_OBJECTS += Pascal/TextWriter.o PASCAL_OBJECTS += Pascal/Entry.o PASCAL_OBJECTS += Pascal/VolumeEntry.o -PROFUSE_OBJECTS += ProFUSE/Exception.o -PROFUSE_OBJECTS += ProFUSE/Lock.o +COMMON_OBJECTS += Common/Lock.o PRODOS_OBJECTS += ProDOS/DateTime.o PRODOS_OBJECTS += ProDOS/Disk.o PRODOS_OBJECTS += ProDOS/File.o +EXCEPTION_OBJECTS += Common/Exception.o +EXCEPTION_OBJECTS += ProDOS/Exception.o +EXCEPTION_OBJECTS += POSIX/Exception.o + + + + all: $(TARGETS) @@ -93,7 +103,8 @@ o/newfs_pascal: bin/newfs_pascal.o \ ${DEVICE_OBJECTS} \ ${ENDIAN_OBJECTS} \ ${FILE_OBJECTS} \ - ${PROFUSE_OBJECTS} \ + ${COMMON_OBJECTS} \ + ${EXCEPTION_OBJECTS} \ ${PASCAL_OBJECTS} $(CC) $(LDFLAGS) $^ $(LIBS) -o $@ @@ -102,7 +113,8 @@ o/apfm: bin/apfm.o \ ${DEVICE_OBJECTS} \ ${ENDIAN_OBJECTS} \ ${FILE_OBJECTS} \ - ${PROFUSE_OBJECTS} \ + ${COMMON_OBJECTS} \ + ${EXCEPTION_OBJECTS} \ ${PASCAL_OBJECTS} $(CC) $(LDFLAGS) $^ $(LIBS) -o $@ @@ -112,7 +124,8 @@ o/fuse_pascal: bin/fuse_pascal.o bin/fuse_pascal_ops.o \ ${DEVICE_OBJECTS} \ ${ENDIAN_OBJECTS} \ ${FILE_OBJECTS} \ - ${PROFUSE_OBJECTS} \ + ${COMMON_OBJECTS} \ + ${EXCEPTION_OBJECTS} \ ${PASCAL_OBJECTS} $(CC) $(LDFLAGS) $^ $(LIBS) $(FUSE_LIBS) -o $@ @@ -123,7 +136,8 @@ o/profuse: bin/profuse.o bin/profuse_dirent.o bin/profuse_file.o \ ${DEVICE_OBJECTS} \ ${ENDIAN_OBJECTS} \ ${FILE_OBJECTS} \ - ${PROFUSE_OBJECTS} \ + ${COMMON_OBJECTS} \ + ${EXCEPTION_OBJECTS} \ ${PRODOS_OBJECTS} $(CC) $(LDFLAGS) $^ $(LIBS) $(FUSE_LIBS) -o $@ @@ -133,59 +147,59 @@ clean: xattr.o: bin/xattr.cpp -newfs_pascal.o: bin/newfs_pascal.cpp Device/BlockDevice.h ProFUSE/Exception.h \ +newfs_pascal.o: bin/newfs_pascal.cpp Device/BlockDevice.h Common/Exception.h \ Device/TrackSector.h Cache/BlockCache.h Device/RawDevice.h File/File.h \ Pascal/Pascal.h Pascal/Date.h fuse_pascal.o: bin/fuse_pascal.cpp Pascal/Pascal.h Pascal/Date.h \ - ProFUSE/Exception.h Device/BlockDevice.h Device/TrackSector.h \ + Common/Exception.h Device/BlockDevice.h Device/TrackSector.h \ Cache/BlockCache.h fuse_pascal_ops.o: bin/fuse_pascal_ops.cpp Pascal/Pascal.h Pascal/Date.h \ - ProFUSE/auto.h ProFUSE/Exception.h + Common/auto.h Common/Exception.h apfm.o: bin/apfm.cpp Pascal/Pascal.h Pascal/Date.h Device/BlockDevice.h \ - ProFUSE/Exception.h Device/TrackSector.h Cache/BlockCache.h + Common/Exception.h Device/TrackSector.h Cache/BlockCache.h -File/File.o: File/File.cpp File/File.h ProFUSE/Exception.h +File/File.o: File/File.cpp File/File.h Common/Exception.h File/MappedFile.o: File/MappedFile.cpp File/MappedFile.h File/File.h \ - ProFUSE/Exception.h + Common/Exception.h Device/Adaptor.o: Device/Adaptor.cpp Device/Adaptor.h Device/TrackSector.h \ - ProFUSE/Exception.h + Common/Exception.h Device/BlockDevice.o: Device/BlockDevice.cpp Device/BlockDevice.h \ - ProFUSE/Exception.h Device/TrackSector.h Cache/BlockCache.h \ + Common/Exception.h Device/TrackSector.h Cache/BlockCache.h \ Cache/ConcreteBlockCache.h Device/DiskImage.h Device/Adaptor.h \ File/MappedFile.h File/File.h Device/UniversalDiskImage.h \ Device/DiskCopy42Image.h Device/DavexDiskImage.h Device/RawDevice.h Device/DavexDiskImage.o: Device/DavexDiskImage.cpp \ Device/DavexDiskImage.h \ - Device/BlockDevice.h ProFUSE/Exception.h Device/TrackSector.h \ + Device/BlockDevice.h Common/Exception.h Device/TrackSector.h \ Cache/BlockCache.h Device/DiskImage.h Device/Adaptor.h \ File/MappedFile.h File/File.h Endian/Endian.h Endian/IOBuffer.h \ Endian/IOBuffer.cpp.h Cache/MappedBlockCache.h Device/DiskCopy42Image.o: Device/DiskCopy42Image.cpp \ Device/DiskCopy42Image.h \ - Device/BlockDevice.h ProFUSE/Exception.h Device/TrackSector.h \ + Device/BlockDevice.h Common/Exception.h Device/TrackSector.h \ Cache/BlockCache.h Device/DiskImage.h Device/Adaptor.h \ File/MappedFile.h File/File.h Endian/Endian.h Endian/IOBuffer.h \ Endian/IOBuffer.cpp.h Cache/MappedBlockCache.h Device/DiskImage.o: Device/DiskImage.cpp Device/DiskImage.h \ - ProFUSE/Exception.h \ + Common/Exception.h \ Device/BlockDevice.h Device/TrackSector.h Cache/BlockCache.h \ Device/Adaptor.h File/MappedFile.h File/File.h Cache/MappedBlockCache.h Device/RawDevice.o: Device/RawDevice.cpp Device/RawDevice.h \ Device/BlockDevice.h \ - ProFUSE/Exception.h Device/TrackSector.h Cache/BlockCache.h File/File.h + Common/Exception.h Device/TrackSector.h Cache/BlockCache.h File/File.h Device/UniversalDiskImage.o: Device/UniversalDiskImage.cpp \ - Device/UniversalDiskImage.h Device/BlockDevice.h ProFUSE/Exception.h \ + Device/UniversalDiskImage.h Device/BlockDevice.h Common/Exception.h \ Device/TrackSector.h Cache/BlockCache.h Device/DiskImage.h \ Device/Adaptor.h File/MappedFile.h File/File.h Endian/Endian.h \ Endian/IOBuffer.h Endian/IOBuffer.cpp.h Cache/MappedBlockCache.h \ @@ -194,45 +208,45 @@ Device/UniversalDiskImage.o: Device/UniversalDiskImage.cpp \ Endian/Endian.o: Endian/Endian.cpp Endian/Endian.h Cache/BlockCache.o: Cache/BlockCache.cpp Cache/BlockCache.h \ - Device/BlockDevice.h ProFUSE/Exception.h Device/TrackSector.h \ - ProFUSE/auto.h + Device/BlockDevice.h Common/Exception.h Device/TrackSector.h \ + Common/auto.h Cache/ConcreteBlockCache.o: Cache/ConcreteBlockCache.cpp \ Device/BlockDevice.h \ - ProFUSE/Exception.h Device/TrackSector.h Cache/BlockCache.h \ - Cache/ConcreteBlockCache.h ProFUSE/auto.h + Common/Exception.h Device/TrackSector.h Cache/BlockCache.h \ + Cache/ConcreteBlockCache.h Common/auto.h Cache/MappedBlockCache.o: Cache/MappedBlockCache.cpp \ Cache/MappedBlockCache.h \ - Cache/BlockCache.h Device/BlockDevice.h ProFUSE/Exception.h \ + Cache/BlockCache.h Device/BlockDevice.h Common/Exception.h \ Device/TrackSector.h -ProFUSE/Exception.o: ProFUSE/Exception.cpp ProFUSE/Exception.h +Common/Exception.o: Common/Exception.cpp Common/Exception.h -ProFUSE/Lock.o: ProFUSE/Lock.cpp ProFUSE/Lock.h +Common/Lock.o: Common/Lock.cpp Common/Lock.h Pascal/Date.o: Pascal/Date.cpp Pascal/Date.h Pascal/Entry.o: Pascal/Entry.cpp Pascal/Entry.h Pascal/Date.h \ - ProFUSE/Exception.h Endian/Endian.h Endian/IOBuffer.h \ + Common/Exception.h Endian/Endian.h Endian/IOBuffer.h \ Endian/IOBuffer.cpp.h Device/BlockDevice.h Device/TrackSector.h \ Cache/BlockCache.h Pascal/FileEntry.o: Pascal/FileEntry.cpp Pascal/Pascal.h Pascal/Date.h \ - Pascal/Entry.h Pascal/FileEntry.h Pascal/VolumeEntry.h ProFUSE/auto.h \ - ProFUSE/Exception.h Endian/Endian.h Endian/IOBuffer.h \ + Pascal/Entry.h Pascal/FileEntry.h Pascal/VolumeEntry.h Common/auto.h \ + Common/Exception.h Endian/Endian.h Endian/IOBuffer.h \ Endian/IOBuffer.cpp.h Device/BlockDevice.h Device/TrackSector.h \ Cache/BlockCache.h Pascal/TextWriter.h Pascal/VolumeEntry.o: Pascal/VolumeEntry.cpp Pascal/Pascal.h Pascal/Date.h \ - Pascal/Entry.h Pascal/FileEntry.h Pascal/VolumeEntry.h ProFUSE/auto.h \ - ProFUSE/Exception.h Endian/Endian.h Endian/IOBuffer.h \ + Pascal/Entry.h Pascal/FileEntry.h Pascal/VolumeEntry.h Common/auto.h \ + Common/Exception.h Endian/Endian.h Endian/IOBuffer.h \ Endian/IOBuffer.cpp.h Device/BlockDevice.h Device/TrackSector.h \ Cache/BlockCache.h Pascal/TextWriter.o: Pascal/TextWriter.cpp Pascal/TextWriter.h \ - Pascal/FileEntry.h Pascal/Entry.h Pascal/Date.h ProFUSE/Exception.h + Pascal/FileEntry.h Pascal/Entry.h Pascal/Date.h Common/Exception.h @@ -243,3 +257,11 @@ ProDOS/Disk.o: ProDOS/Disk.cpp ProDOS/Disk.h ProDOS/File.o: ProDOS/File.cpp ProDOS/File.h +ProDOS/Exception.o: ProDOS/Exception.cpp ProDOS/Exception.h Common/Exception.h + +NuFX/Exception.o: NuFX/Exception.cpp NuFX/Exception.h Common/Exception.h + +POSIX/Exception.o: POSIX/Exception.cpp POSIX/Exception.h Common/Exception.h + + + diff --git a/Pascal/Entry.cpp b/Pascal/Entry.cpp index 6cb406e..176b5bb 100644 --- a/Pascal/Entry.cpp +++ b/Pascal/Entry.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include diff --git a/Pascal/Entry.h b/Pascal/Entry.h index 7fe8605..f367bf7 100644 --- a/Pascal/Entry.h +++ b/Pascal/Entry.h @@ -1,7 +1,7 @@ #ifndef __PASCAL_ENTRY_H__ #define __PASCAL_ENTRY_H__ -#include +#include namespace Device { diff --git a/Pascal/FileEntry.cpp b/Pascal/FileEntry.cpp index 35ba7ee..7d54bbc 100644 --- a/Pascal/FileEntry.cpp +++ b/Pascal/FileEntry.cpp @@ -8,8 +8,9 @@ #include #include -#include -#include +#include +#include +#include #include #include @@ -77,7 +78,7 @@ FileEntry::FileEntry(const char *name, unsigned fileKind) unsigned length = ValidName(name); if (!length) - throw ProFUSE::Exception(__METHOD__ ": Invalid file name."); + throw ::Exception(__METHOD__ ": Invalid file name."); _fileKind = fileKind; _status = 0; @@ -126,7 +127,7 @@ void FileEntry::setName(const char *name) unsigned length = ValidName(name); if (!length) - throw ProFUSE::ProDOSException(__METHOD__ ": Invalid file name.", ProFUSE::badPathSyntax); + throw ProDOS::Exception(__METHOD__ ": Invalid file name.", ProDOS::badPathSyntax); _fileNameLength = length; for (unsigned i = 0; i < length; ++i) @@ -523,7 +524,7 @@ int FileEntry::textRead(uint8_t *buffer, unsigned size, unsigned offset) unsigned l; unsigned count = 0; - ProFUSE::auto_array tmp; + ::auto_array tmp; unsigned tmpSize = 0; if (!_pageSize) textInit(); diff --git a/Pascal/TextWriter.cpp b/Pascal/TextWriter.cpp index 309f4f4..b1d2563 100644 --- a/Pascal/TextWriter.cpp +++ b/Pascal/TextWriter.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include @@ -89,7 +89,7 @@ void TextWriter::writeLine(const char *line, unsigned length) if (length > 1024) { - throw ProFUSE::Exception(__METHOD__ ": String is too long."); + throw ::Exception(__METHOD__ ": String is too long."); } if (_offset + length > 1024) { diff --git a/Pascal/VolumeEntry.cpp b/Pascal/VolumeEntry.cpp index 60ee49e..07e3453 100644 --- a/Pascal/VolumeEntry.cpp +++ b/Pascal/VolumeEntry.cpp @@ -5,8 +5,9 @@ #include -#include -#include +#include +#include +#include #include #include @@ -21,9 +22,6 @@ using namespace Pascal; using namespace Device; -using ProFUSE::Exception; -using ProFUSE::ProDOSException; -using ProFUSE::POSIXException; enum { kMaxFiles = 77 @@ -111,13 +109,13 @@ VolumeEntry::VolumeEntry(Device::BlockDevicePointer device, const char *name) : deviceBlocks = std::min(0xffffu, deviceBlocks); if (deviceBlocks < 6) - throw Exception(__METHOD__ ": device too small."); + throw ::Exception(__METHOD__ ": device too small."); length = ValidName(name); if (!length) - throw ProDOSException(__METHOD__ ": Invalid volume name.", ProFUSE::badPathSyntax); + throw ProDOS::Exception(__METHOD__ ": Invalid volume name.", ProDOS::badPathSyntax); _firstBlock = 0; _lastBlock = 6; @@ -164,7 +162,7 @@ VolumeEntry::VolumeEntry(Device::BlockDevicePointer device) { unsigned blockCount; //unsigned deviceBlocks = device->blocks(); - ProFUSE::auto_array buffer(new uint8_t[512]); + ::auto_array buffer(new uint8_t[512]); // read the header block, then load up all the header @@ -234,7 +232,7 @@ VolumeEntry::VolumeEntry(Device::BlockDevicePointer device) error = true; if (error) - throw ProDOSException(__METHOD__ ": Invalid file entry.", ProFUSE::dirError); + throw ProDOS::Exception(__METHOD__ ": Invalid file entry.", ProDOS::dirError); block = e->_lastBlock; @@ -274,7 +272,7 @@ void VolumeEntry::init(void *vp) // verify filenamelength <= 7 if (_fileNameLength > 7) - throw ProDOSException(__METHOD__ ": invalid name length", ProFUSE::badPathSyntax); + throw ProDOS::Exception(__METHOD__ ": invalid name length", ProDOS::badPathSyntax); // verify fileKind == 0 // verify _fileCount reasonable @@ -367,7 +365,7 @@ int VolumeEntry::unlink(const char *name) } // need to update the header blocks. - ProFUSE::auto_array buffer(readDirectoryHeader()); + ::auto_array buffer(readDirectoryHeader()); // update the filecount. @@ -596,7 +594,7 @@ FileEntryPointer VolumeEntry::create(const char *name, unsigned blocks) entry = FileEntry::Create(name, kUntypedFile); - ProFUSE::auto_array buffer(readDirectoryHeader()); + ::auto_array buffer(readDirectoryHeader()); for (iter = _files.begin(); iter != _files.end(); ++iter) { @@ -740,13 +738,13 @@ int VolumeEntry::krunch() if (first != prevBlock) gap = true; if (first < prevBlock) - return ProFUSE::damagedBitMap; + return ProDOS::damagedBitMap; if (last < first) - return ProFUSE::damagedBitMap; + return ProDOS::damagedBitMap; if (first < volumeBlocks()) - return ProFUSE::damagedBitMap; + return ProDOS::damagedBitMap; prevBlock = last; @@ -758,7 +756,7 @@ int VolumeEntry::krunch() // need to update the header blocks. - ProFUSE::auto_array buffer(readDirectoryHeader()); + ::auto_array buffer(readDirectoryHeader()); IOBuffer b(buffer.get(), 512 * blocks()); @@ -956,7 +954,7 @@ void VolumeEntry::writeDirectoryHeader(void *buffer) uint8_t *VolumeEntry::readBlocks(unsigned startingBlock, unsigned count) { - ProFUSE::auto_array buffer(new uint8_t[512 * count]); + ::auto_array buffer(new uint8_t[512 * count]); for (unsigned i = 0; i < count; ++i) _cache->read(startingBlock + i, buffer.get() + 512 * i); @@ -1001,7 +999,7 @@ void VolumeEntry::writeEntry(FileEntry *e) else { // crosses page boundaries. - ProFUSE::auto_array buffer(readBlocks(startBlock, 2)); + ::auto_array buffer(readBlocks(startBlock, 2)); IOBuffer b(buffer.get() + offset, 0x1a); diff --git a/bin/apfm.cpp b/bin/apfm.cpp index 50fb5d2..23b2f37 100644 --- a/bin/apfm.cpp +++ b/bin/apfm.cpp @@ -1067,7 +1067,7 @@ int main(int argc, char **argv) usage(); return 3; } - catch (ProFUSE::Exception& e) + catch (Exception& e) { std::fprintf(stderr, "%s\n", e.what()); std::fprintf(stderr, "%s\n", e.errorString()); diff --git a/bin/fuse_pascal.cpp b/bin/fuse_pascal.cpp index 2f6d72a..d384486 100644 --- a/bin/fuse_pascal.cpp +++ b/bin/fuse_pascal.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include @@ -216,17 +216,13 @@ int main(int argc, char **argv) volume = Pascal::VolumeEntry::Open(device); } - catch (ProFUSE::POSIXException &e) + catch (::Exception &e) { std::fprintf(stderr, "%s\n", e.what()); std::fprintf(stderr, "%s\n", std::strerror(e.error())); return -1; } - catch (ProFUSE::Exception &e) - { - std::fprintf(stderr, "%s\n", e.what()); - return -1; - } + diff --git a/bin/fuse_pascal_ops.cpp b/bin/fuse_pascal_ops.cpp index 31c8509..d44ac32 100644 --- a/bin/fuse_pascal_ops.cpp +++ b/bin/fuse_pascal_ops.cpp @@ -26,8 +26,9 @@ #include -#include -#include +#include +#include +#include #define NO_ATTR() \ { \ @@ -264,7 +265,7 @@ static void pascal_readdir(fuse_req_t req, fuse_ino_t ino, size_t size, off_t of DEBUGNAME() VolumeEntry *volume = (VolumeEntry *)fuse_req_userdata(req); - ProFUSE::auto_array buffer(new uint8_t[size]); + ::auto_array buffer(new uint8_t[size]); unsigned count = volume->fileCount(); @@ -502,13 +503,14 @@ static void pascal_read(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, try { - ProFUSE::auto_array buffer(new uint8_t[size]); + ::auto_array buffer(new uint8_t[size]); unsigned rsize = file->read(buffer.get(), size, off); fuse_reply_buf(req, (char *)(buffer.get()), rsize); return; } - catch (ProFUSE::POSIXException &e) + + catch (POSIX::Exception &e) { printf("posix error...\n"); ERROR(true, e.error()); diff --git a/bin/newfs_pascal.cpp b/bin/newfs_pascal.cpp index 7b1bbb0..fb08a2b 100644 --- a/bin/newfs_pascal.cpp +++ b/bin/newfs_pascal.cpp @@ -14,7 +14,7 @@ #include -#include +#include #include @@ -302,17 +302,13 @@ int main(int argc, char **argv) } - catch (ProFUSE::POSIXException& e) + catch (::Exception& e) { std::fprintf(stderr, "%s\n", e.what()); std::fprintf(stderr, "%s\n", ::strerror(e.error())); return -2; } - catch (ProFUSE::Exception& e) - { - std::fprintf(stderr, "%s\n", e.what()); - return -2; - } + return 0; } diff --git a/bin/profuse.cpp b/bin/profuse.cpp index 62dff80..1c8675a 100644 --- a/bin/profuse.cpp +++ b/bin/profuse.cpp @@ -280,7 +280,7 @@ int main(int argc, char *argv[]) } } - catch (ProFUSE::Exception &e) + catch (::Exception &e) { std::fprintf(stderr, "%s\n", e.what()); std::fprintf(stderr, "%s\n", e.errorString());