General discussion

  • Creator
    Topic
  • #2102287

    FAT32 Pseudo Code

    Locked

    by g_plumb ·

    I am having some difficulty with reading and writing FAT32 partitions. Assuming the bios uses lba access (to the disk – ie. a 32bit number as opposed to a CHS value), 2500 points are available to the first person to post a pseudo code for traversing dirs, files to read and write them.

    Thanks

All Comments

  • Author
    Replies
    • #3707171

      FAT32 Pseudo Code

      by maxwell edison ·

      In reply to FAT32 Pseudo Code

      Here’s a function that prints all the entries, both files and subdirectories, in the directory dirName.

      void PrintDir(const apstring& dirName)
      {
      DirStream input(dirName);
      for(input.Init(); input.HasMore(); input.Next()){
      DirEntry entry = input.Current();
      cout << entry.Name() << "\t" << entry.Size() << endl; } } That's it! The function prints the names of every file/subdirectory and the file size. Good luck, Max

      • #3707169

        FAT32 Pseudo Code

        by maxwell edison ·

        In reply to FAT32 Pseudo Code

        .
        .
        For recursion, this program prints everything, all the way down: subdirectories and their contents, and their subdirectory contents and so on.

        #include
        #include

        #include “apstring.h”
        #include “directory.h”

        // Owen Astrachan, 4/18/95, 5/10/99
        // print all entries in a directory (uses recursion)

        void Tab(int count)
        // postcondition: count tabs printed to cout
        {
        int k;
        for(k=0; k < count; k++) { cout << "\t"; } } void ProcessDir(const apstring & path, int tabCount) // precondition: path specifies pathname to a directory // tabCount specifies how many tabs for printing // postcondition: all files and subdirectories in directory 'path' // printed, subdirectories tabbed over 1 more than parent { DirStream indir(path); DirEntry entry; int num = 0; // number of files in this directory if (! indir.fail()) // directory opened successfully? { for(indir.Init(); indir.HasMore(); indir.Next()) { entry = indir.Current(); // either file or subdirectory // don't process self: ".", or parent directory: ".." if (entry.Name() != "." && entry.Name() != "..") { num++; Tab(tabCount); // print spaces cout << "(" << setw(4) << num << ") " << entry.Size() << "\t" << entry.Name() << endl; // and name if (entry.IsDir() ) // process subdir { ProcessDir(entry.Path(),tabCount+1); } } } } // end if (! fail)} int main() { apstring dirname; cout << "enter directory name "; cin >> dirname;
        ProcessDir(dirname,0);
        return 0;
        }

      • #3718152

        FAT32 Pseudo Code

        by g_plumb ·

        In reply to FAT32 Pseudo Code

        Maybe I wan’t clear in the question/request – although the above is not wrong – I am talking a general algorithm I can apply in any language. Here you have posted some C/C++ code using directory.h – although this is OK, it is not what I am trying to do. I am trying to access drives directly, without DOS or any sort of OS intervening! The question, and the points, are wide open for anyone that can help!!! Thanx

    • #3625619

      FAT32 Pseudo Code

      by maxwell edison ·

      In reply to FAT32 Pseudo Code

      Greetings (again),

      Well, you may reject this (correct) answer as well, just like you rejected the last (correct) one. But I’ve gotten used to rejection. 🙁 🙁

      Nonetheless, I came back to this question because your “follow up” criteria were rather intriguing – accessing files on a disk WITHOUT the use of an operating system. Correct me if I’m mistaken, but the ONLY way to circumvent an operating system from taking control of the computer is to interrupt that control by directing the BIOS to take control. After all, something has to control the computer, doesn’t it? Are you asking for code that can be put on a floppy disk, for instance, that will allow you to boot up on that disk and do all (or some of) the things that an “operating system” will allow you to do? That’s what it sounds like to me. And that?s what a DOS boot disk does. (And with that method you could use the ?code? I previously posted.) Why re-create the wheel? (I will admit that I’m rather curious as to yourreasoning, but that’s beside the point, I suppose.)

      The bottom line, however, is that you want the code to do that. Regardless of who writes the code, you or I, or someone else, I suppose it doesn’t really matter, does it? Working on that premise, instead of providing the code myself, I’ll focus on finding something that will achieve your stated desired outcome – accessing files on a disk WITHOUT an operating system – with code written by someone else (software).

      (continued in comments …)

      • #3625615

        FAT32 Pseudo Code

        by maxwell edison ·

        In reply to FAT32 Pseudo Code

        .
        .
        (continued from above ….)

        I thought that software like Partition Magic would be possible, but I don?t believe that will allow you to directly access those files as you?ve described. But I DID run across some software (code written by someone else) that appears to have a feature that will allow you to do what you want. Namely, accessing files on a disk WITHOUT an operating system.

        The software is called: PARAGON ADVANCED BOOTMANAGER 5.0

        Go to this link (REMOVE SPACES if they snuck in while pasting):

        http://www.paragon-gmbh.com/n_bm.htm

        They “claim” to (soon) have a feature that will have, in their words, the following capability: “Special utility Partition Explorer allows user to access partitions none supported by running OS (like Ext2FS partitions under Windows 9x/NT/2000 or NTFS partitions under DOS or Windows 9x).

        Here?s another one that looked quite interesting. It?s ?code? written by a chap named, Erich Boleyn, that does indeed ?take control? of the computer. His description is as follows: ?Briefly, bootloader is the first software program that runs when a computer starts. It is responsible for loading and transferring control to the operating system kernel software?.

        Go to this link (REMOVE SPACES if they snuck in while pasting):

        http://www.gnu.org/software/grub/

        Well, I?ve given you about as much of my time (attempting to answer this question) as I?m willing to give. I must say, however, it?s been quite interesting. Actually, I?d be very interested in hearing more about your ?problem? and any solution you may find. Feel free to e-mail me if you feel so inclined. Best of luck to you.

        Regards,

        Maxwell

      • #3625560

        FAT32 Pseudo Code

        by g_plumb ·

        In reply to FAT32 Pseudo Code

        OK, first off, rejection is your problem… ;P

        OK, You hit on, briefly, what I wanted to do. I was writing part of an OS, and need to use the BIOS to access the disk – the easy part. What I actually needed was an algorithm to allow me to interpret the data chunks from disk (called blocks) assuming the FAT32 encoding and extract data from it.

        The problem has since been dealt with, so thanks for your participation.

    • #3625559

      FAT32 Pseudo Code

      by g_plumb ·

      In reply to FAT32 Pseudo Code

      This question was closed by the author

Viewing 2 reply threads