well

this is not the "right" way to do what you want to do...altough it seems to work, despite any possible problems with FreeCOM

DOS has its own, more elegant, API for file/directory listing...look for functions findfirst/findnext...they should be avaliable on your C compiler...

On 9/18/06, Marton <[EMAIL PROTECTED]> wrote:

Absolutely, the function is simple... just to see if two directories that
should have the same contents changed. Here it goes (hope it indents well):

int checkdir(void) {
    int i, filesize = 0;
    FILE *fp, *fp2;

    system("dir c:\\data\\base1 >c:\\data.dir");
    fp = fopen("c:\\data.dir","r");
    fp2 = fopen("c:\\dataorig.dir","r");
    fseek(fp, 0, SEEK_END);
    filesize = ftell(fp);
    fseek(fp2, 0, SEEK_END);
    if(filesize != ftell(fp2))
      filesize = -1;
    rewind(fp); rewind(fp2);

    for(i=0;i<filesize;i++)
    {
      int file1data = 0, file2data = 0;
      fread(&file1data,1,1,fp);
      fread(&file2data,1,1,fp2);
      if(file1data != file2data)
        break;
    }

    if(i != filesize)
      return 1;
    else
      return 0;

    fclose(fp);
    fclose(fp2);
    remove("c:\\data.dir");
    remove("c:\\dataorig.dir");
  }
}

This always returns 1 because the file data.dir gets cut so the compare with
dataorig.dir always fails.

Thanks!!

Marton


--
Daniel

"Let us change our traditional attitude to the construction of programs. Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do." (Donald Knuth)

"Yes, technogeeks can be funny, even if only to each other." (http://www.boogieonline.com/revolution/science/humor/)"

"Man is driven to create; I know I really love to create things. And while I'm not good at painting, drawing, or music, I can write software." (Yukihiro Matsumoto, a.k.a. ``Matz'')
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user

Reply via email to