fork from va009039/USBLocalFileSystem

Dependencies:   USBDevice

Dependents:   11u35_usbLocalFilesystem

Fork of USBLocalFileSystem by Norimasa Okamoto

Revision:
0:39eb4d5b97df
Child:
1:00c9eb8af5c2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBLocalFileSystem.cpp	Sat May 03 11:21:37 2014 +0000
@@ -0,0 +1,56 @@
+#include "USBLocalFileSystem.h"
+#include "RamDisk.h"
+#include "SDStorage.h"
+
+USBLocalFileSystem::USBLocalFileSystem(const char* name)
+{
+    RamDisk* storage = new RamDisk;
+    init(storage, name);
+}
+
+USBLocalFileSystem::USBLocalFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name)
+{
+    SDStorage* storage = new SDStorage(mosi, miso, sclk, cs);
+    storage->storage_initialize();
+    init(storage, name);
+}
+
+USBLocalFileSystem::USBLocalFileSystem(StorageInterface* storage, const char* name)
+{
+    init(storage, name);
+}
+
+void USBLocalFileSystem::init(StorageInterface* storage, const char* name)
+{
+    _name = name;
+    _storage = storage;
+    _usb = new USBStorage2(_storage);
+    _local = new LocalStorage(_storage);    
+}
+
+void USBLocalFileSystem::attachEvent(void (*ptr)())
+{
+    if (ptr && _storage) {
+         _storage->attachEvent(ptr);
+     }
+}
+
+void USBLocalFileSystem::remount()
+{
+    if (_local) {
+        delete _local;
+    }    
+    _local = new LocalStorage(_storage); 
+}
+
+void USBLocalFileSystem::putc(int c)
+{
+    _usb->putc(c);
+}
+
+int USBLocalFileSystem::getc()
+{
+    return _usb->getc();
+}
+
+    
\ No newline at end of file