diff --git a/BlockDevice.cpp b/BlockDevice.cpp index e75bef8..3463965 100644 --- a/BlockDevice.cpp +++ b/BlockDevice.cpp @@ -114,6 +114,7 @@ ProDOSOrderDiskImage::ProDOSOrderDiskImage(MappedFile *file) : ProDOSOrderDiskImage *ProDOSOrderDiskImage::Create(const char *name, size_t blocks) { MappedFile *file = new MappedFile(name, blocks * 512); + file->setBlocks(blocks); return new ProDOSOrderDiskImage(file); } @@ -154,6 +155,7 @@ DOSOrderDiskImage *DOSOrderDiskImage::Create(const char *name, size_t blocks) { MappedFile *file = new MappedFile(name, blocks * 512); file->setEncoding(MappedFile::DOSOrder); + file->setBlocks(blocks); return new DOSOrderDiskImage(file); } diff --git a/Entry.cpp b/Entry.cpp index 15b84b1..3d3d982 100644 --- a/Entry.cpp +++ b/Entry.cpp @@ -52,7 +52,11 @@ unsigned Entry::ValidName(const char *name) for (length = 1; length < 17; ++length) { - if (!isalnumdot(name[length])) return 0; + char c = name[length]; + if (isalnumdot(c)) continue; + if (c == 0) break; + + return 0; } if (length > 15) return 0; diff --git a/Makefile b/Makefile index 552e7d1..840038b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ CC = g++ -CPPFLAGS += -Wall -O2 +CPPFLAGS += -Wall -O2 -g newfs_prodos: \ newfs_prodos.o \ diff --git a/VolumeDirectory.cpp b/VolumeDirectory.cpp index f4c8df1..1f81c14 100644 --- a/VolumeDirectory.cpp +++ b/VolumeDirectory.cpp @@ -58,12 +58,11 @@ VolumeDirectory::VolumeDirectory(const char *name, BlockDevice *device) : device->write(i, buffer.buffer()); } - // TODO -- create/write the volume entry.... - + // allocate blocks for the bitmap itself unsigned bb = bitmap->bitmapBlocks(); for (unsigned i = 0; i < bb; ++i) - bitmap->allocBlock(i); + bitmap->allocBlock(_bitmapPointer + i); // now write the bitmap... const uint8_t *bm = (const uint8_t *)bitmap->bitmap(); diff --git a/newfs_prodos.cpp b/newfs_prodos.cpp index e4d1728..a8dd84d 100644 --- a/newfs_prodos.cpp +++ b/newfs_prodos.cpp @@ -1,20 +1,21 @@ -#include "BlockDevice.h" -#include "UniversalDiskImage.h" -#include "DiskCopy42Image.h" -#include "DavexDiskImage.h" -#include "RawDevice.h" -#include "Exception.h" - #include #include #include #include #include - #include #include +#include "BlockDevice.h" +#include "DavexDiskImage.h" +#include "DiskCopy42Image.h" +#include "Entry.h" +#include "Exception.h" +#include "RawDevice.h" +#include "UniversalDiskImage.h" + + #define NEWFS_VERSION "0.1" using namespace ProFUSE; @@ -244,7 +245,7 @@ int main(int argc, char **argv) try { std::auto_ptr device; - //auto_ptr volume; + std::auto_ptr volume; // todo -- check if path matches /dev/xxx; if so, use RawDevice. // todo -- check if file exists at path? @@ -252,7 +253,6 @@ int main(int argc, char **argv) switch(format) { case 'DC42': - // todo -- pass in volume name device.reset(DiskCopy42Image::Create(fname, blocks, volumeName.c_str())); break; @@ -275,7 +275,7 @@ int main(int argc, char **argv) // VolumeDirectory assumes ownership of device, // but doesn't release it on exception. - //volume.reset(new VolumeDirectory(name, device)); + volume.reset(new VolumeDirectory(volumeName.c_str(), device.get())); device.release(); }