Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

OSFile#2

236 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

OSFile#2

  1. 1. OSFile #2 Interface & API
  2. 2. Classes OSF_Directory Templates OSF_Exception OSF_DiskList OSF_File OSF_FileSystem Interfaces OSF_PlainAPI OSF_DirectoryInterface OSF_TestUnit OSF_FileInterface OSF_Types OSF_VHDDInterface OSF_VHDD OSF_DiskListInterface OSF_FileSystemInterface
  3. 3. OSF_PlainAPI
  4. 4. Easy to use You can use OSF_PlainAPI to easy non-object oriented access.
  5. 5. OSF_PlainAPI OSF_FileHandle* OSF_Open(string path); void OSF_Close(OSF_FileHandle* fileHandle); OSF_PlainAPIInt OSF_Read(OSF_FileHandle* fileHandle, void* buf, OSF_PlainAPIInt count); OSF_PlainAPIInt OSF_Write(OSF_FileHandle* fileHandle, void* buf, OSF_PlainAPIInt count); void OSF_Ls(string path, void (*callback)(OSF_DirRecord*)); OSF_OWNER OSF_chownFile(string path); void OSF_chownFile(OSF_OWNER owner, string path); OSF_PERMISSION OSF_chmodFile(string path); void OSF_chmodFile(OSF_PERMISSION permission, string path); void OSF_remove(string dir, string filename);
  6. 6. Console example #1 if (command == "write") { string filename; cin >> filename; cin >> buffer; OSF_FileHandle* handle = OSF_Open(path + "/" + filename, true); OSF_Write(handle, buffer, sizeof (buffer)); OSF_Close(handle); }
  7. 7. Console example #2 if (command == "ls") { OSF_Ls(path, &ls_print); cout << endl; }
  8. 8. Console example #3 if (command == "setowner") { string filename; cin >> filename; OSF_OWNER owner; cin >> owner; OSF_chownFile(owner, path + "/" + filename); }
  9. 9. OOP Object Oriented Programing
  10. 10. Interfaces OSF_Types - contain type and preprocessor macros OSF_VHDDInterface - represent your virtual hard disk OSF_FileSystemInterface - represent file system on the virtual hard disk OSF_DirectoryInterface - represent a directory OSF_FileInterface - represent a file OSF_DiskListInterface - provide data organization interface
  11. 11. example #create //Create new virtual hard disk vHDD = new OSF_VHDD(filePath 128, 80, true); //create new file system of the disk OSF_FileSystemHeader header; OSF_scpy(header.diskName, "testDisk"); fileSystem = new OSF_FileSystem(vHDD, &header, 2);
  12. 12. example #create direcotry OSF_DirectoryInterface* rootDir = plainAPIData->fs->getRootDir(); OSF_DirectoryInterface* d1 = rootDir->createDir("d1"); OSF_DirectoryInterface* d2_1 = d1->createDir("d2_1"); OSF_DirectoryInterface* d2_2 = d2_1->createDir("d2_2"); OSF_DirectoryInterface* d3 = d2_1->createDir("d3"); //…. OR rootDir->mkdir(“d1/d2/d3/d4/…”);
  13. 13. example #file //create OSF_FileInterface* file = directory->createFile("f1"); //write to file int bufSize = clusterSize * clusterCount; char* buf = testUnit->createBuffer(bufSize); //random data f1->write(buf, 0, 2);
  14. 14. OSF_Directory & OSF_File
  15. 15. Tests
  16. 16. Test classes System contain OSF_TestUnit. The class provide interface for c++ testing. Make possible integrate OSF tests with NetBeans IDE and other graphic interfaces.
  17. 17. Tests
  18. 18. https://github.com/SebastianPozoga/OSFile
  19. 19. Biblografia “Jądro systemu UNIX” - Vahalia - Nowe horyzonty “Anatomia PC. Wydanie X”, Piotr Metzger Helion

×