low level disk access under Windows

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

low level disk access under Windows

pianoman-3
        Hello, I'd like to ask if someone has experiences with low level
disk operations in windows with FPC.
The program should be able to copy entire diskete to one single image file
and for example extract a single file from that image or view its contents.

For example how can I read one sector from disk in to buffer?
Thanx for help
Pianoman
----- Original Message -----
From: <[hidden email]>
To: <[hidden email]>
Sent: Friday, October 06, 2006 1:31 PM
Subject: fpc-pascal Digest, Vol 26, Issue 16


> Send fpc-pascal mailing list submissions to
> [hidden email]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> or, via email, send a message with subject or body 'help' to
> [hidden email]
>
> You can reach the person managing the list at
> [hidden email]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of fpc-pascal digest..."
>
>
> Today's Topics:
>
>   1. Re:  Re: fpUnit - AssertEquals gives Access violation
>      (Vincent Snijders)
>   2.  [libtar.pas]:Error: Illegal type conversion: "ShortString"
>      to "^Char" without compilator options (TOUZEAU DAVID)
>   3. Re:  [libtar.pas]:Error: Illegal type conversion:
>      "ShortString" to "^Char" without compilator options (Vincent
> Snijders)
>   4. Re:  Last missing benchmark: regex-dna (Marco van de Voort)
>   5. Re:  Re: fpUnit - AssertEquals gives Access violation
>      (Graeme Geldenhuys)
>   6. Re:  [libtar.pas]:Error: Illegal type conversion:
>      "ShortString" to "^Char" without compilator options (TOUZEAU DAVID)
>   7.  RE: Get Local IP using glib (eth0,eth1) (Jeff Pohlmeyer)
>   8. Re:  RE: Get Local IP using glib (eth0,eth1) (Marco van de Voort)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 06 Oct 2006 11:58:16 +0200
> From: Vincent Snijders <[hidden email]>
> Subject: Re: [fpc-pascal] Re: fpUnit - AssertEquals gives Access
> violation
> To: FPC-Pascal users discussions <[hidden email]>
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Graeme Geldenhuys schreef:
>> Oh, I forgot to mention.  If the ObjectStates match, the test passes
>> fine, and doesn't give an access violation.
>>
>> While creating the new AssertEquals method, I purposefully created a
>> failure with then gives the access violation, instead to the
>> comparison message I expected:
>>  "Failing on 1: Expected <posClean> but got <posEmpty>"
>>
>
> Try creating a back trace, maybe that gives some insight.
>
> Vincent
>
>
> ------------------------------
>
> Message: 2
> Date: Fri, 06 Oct 2006 12:17:20 +0200
> From: TOUZEAU DAVID <[hidden email]>
> Subject: [fpc-pascal] [libtar.pas]:Error: Illegal type conversion:
> "ShortString" to "^Char" without compilator options
> To: FPC-Pascal users discussions <[hidden email]>
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Dear
>
> I would like to use some units developped from delphi/klyx with Lazarus
> IDE On Linux.
>
> It seems that there is some differences between delphi/freepascal
> especially for longstring conversion.
>
> Many times, i received this compilator error :
>
> For example by using the LibTar.pas
> (http://www.destructor.de/libtar/index.htm)
>
> libtar.pas(355,8) Error: Illegal type conversion: "ShortString" to "^Char"
>
> i fixed this error with  {$H+}{$LongString On} tokens
>
> But is it this good way ??? is there an another solution ??
>
> Best regards.
>
> --
>
> David Touzeau -------------------------- Linux Ubuntu Dapper 6.0.6
> FreePascal-Lazarus,perl,delphi,php icq:160018849
>
>
> ------------------------------
>
> Message: 3
> Date: Fri, 06 Oct 2006 12:19:46 +0200
> From: Vincent Snijders <[hidden email]>
> Subject: Re: [fpc-pascal] [libtar.pas]:Error: Illegal type conversion:
> "ShortString" to "^Char" without compilator options
> To: [hidden email], FPC-Pascal users discussions
> <[hidden email]>
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> TOUZEAU DAVID schreef:
>> Dear
>>
>> I would like to use some units developped from delphi/klyx with Lazarus
>> IDE On Linux.
>>
>> It seems that there is some differences between delphi/freepascal
>> especially for longstring conversion.
>>
>> Many times, i received this compilator error :
>>
>> For example by using the LibTar.pas
>> (http://www.destructor.de/libtar/index.htm)
>>
>> libtar.pas(355,8) Error: Illegal type conversion: "ShortString" to
>> "^Char"
>>
>> i fixed this error with  {$H+}{$LongString On} tokens
>>
>> But is it this good way ??? is there an another solution ??
>
> An alternative is to add {$mode delphi} to the source file or compile
> with -Sd
> compiler option.
>
> Vincent
>
>
> ------------------------------
>
> Message: 4
> Date: Fri, 6 Oct 2006 12:32:52 +0200 (CEST)
> From: [hidden email] (Marco van de Voort)
> Subject: Re: [fpc-pascal] Last missing benchmark: regex-dna
> To: ???? ??????????? <[hidden email]>, FPC-Pascal users discussions
> <[hidden email]>
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset="US-ASCII"
>
>> > Although fpc has a regexpr unit:
>> > http://svn.freepascal.org/svn/fpc/trunk/packages/base/regexpr/regexpr.pp
>> > It has many todos, such as adding support for | in the search
>> > expression. So this
>> > unit doesn't have enough functionality.
>>
>> While '|' support is to be considered basic regex functionality, what is
>> the really expected functionality?
>>
>> Basic seems to be: |()?*+ (non-UNICODE) support (from wikipedia).
>
> | is not basic afaik. From re_format BSD Manpage:
>
>     Obsolete (``basic'') regular expressions differ in several respects.
> `|'
>     is an ordinary character and there is no equivalent for its
> functional-
>     ity.  `+' and `?' are ordinary characters, and their functionality can
>     be expressed using bounds (`{1,}' or `{0,1}' respectively).  Also note
>     that `x+' in modern REs is equivalent to `xx*'.  The delimiters for
>     bounds are `\{' and `\}', with `{' and `}' by themselves ordinary
>     characters.  The parentheses for nested subexpressions are `\(' and
>     `\)', with `(' and `)' by themselves ordinary characters.  `^' is an
>     ordinary character except at the beginning of the RE or= the beginning
>     of a parenthesized subex- pression, `$' is an ordinary character
> except
>     at the end of the RE or= the end of a parenthesized subexpression, and
>     `*' is an ordinary charac- ter if it appears at the beginning of the
> RE
>     or the beginning of a paren- thesized subexpression (after a possible
>     leading `^').  Finally, there is one new type of atom, a back
>     reference: `\' followed by a non-zero deci- mal digit d matches the
>     same sequence of characters matched by the dth parenthesized
>     subexpression (numbering subexpressions by the positions of their
>     opening parentheses, left to right), so that (e.g.) `\([bc]\)\1'
>     matches `bb' or `cc' but not `bc'.
>
>
>
> ------------------------------
>
> Message: 5
> Date: Fri, 6 Oct 2006 12:54:44 +0200
> From: "Graeme Geldenhuys" <[hidden email]>
> Subject: Re: [fpc-pascal] Re: fpUnit - AssertEquals gives Access
> violation
> To: "FPC-Pascal users discussions" <[hidden email]>
> Message-ID:
> <[hidden email]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Here is the backtrace.  I removed all other Assert tests, so only the
> one that causes the problem is executed.
>
> What is strange though, is that I created a new test that only creates
> the object and then tests the ObjectState. It it works, but all the
> other actual tests don't.  I hate such problems! :-)
>
> Graeme.
>
>
> --------------  Start ---------------
> [New Thread -1216787536 (LWP 20619)]
> [Switching to Thread -1213515552 (LWP 20607)]
>
> Breakpoint 1, 0x0805f036 in fpc_raiseexception ()
> (gdb) bt
> #0  0x0805f036 in fpc_raiseexception ()
> #1  0x082189d9 in FPCUNIT_TASSERT_$__FAIL$ANSISTRING ()
> #2  0xb7f04ac0 in ?? ()
> #3  0xb7a69200 in ?? ()
> #4  0x082189ff in FPCUNIT_TASSERT_$__ASSERTTRUE$ANSISTRING$BOOLEAN ()
> #5  0xb7f04ac0 in ?? ()
> #6  0x08218b45 in
> FPCUNIT_TASSERT_$__ASSERTEQUALS$ANSISTRING$ANSISTRING$ANSISTRING ()
> #7  0x080a0202 in TNODEDATATEST__ASSERTEQUALS (PMESSAGE=0x8350cf0,
>    PEXPECTED=POSDELETED, PACTUAL=POSCLEAN, this=0xb7a77a68)
>    at NodeData_test.pas:89
> #8  0x080a1cb7 in TNODEDATATEST__TESTNODECOMPOUND_SAVE2 (this=0xb7a77a68)
>    at NodeData_test.pas:408
> #9  0x0821abf1 in FPCUNIT_TTESTCASE_$__RUNTEST ()
> #10 0x0821ab38 in FPCUNIT_TTESTCASE_$__RUNBARE ()
> #11 0x0821ba67 in FPCUNIT_PROTECTTEST$TTEST$TTESTRESULT ()
> #12 0x0821bb61 in FPCUNIT_TTESTRESULT_$__RUNPROTECTED$TTEST$TPROTECT ()
> #13 0x0821ba9e in FPCUNIT_TTESTRESULT_$__RUN$TTESTCASE ()
> #14 0xb7a77a68 in ?? ()
> #15 0xb7a7cb68 in ?? ()
> #16 0x0821aaeb in FPCUNIT_TTESTCASE_$__RUN$TTESTRESULT ()
> #17 0x0821b4f1 in FPCUNIT_TTESTSUITE_$__RUNTEST$TTEST$TTESTRESULT ()
> #18 0x083ee660 in _$FPCUNIT$_Ld19 ()
> ---Type <return> to continue, or q <return> to quit---
> #19 0x0821b4cb in FPCUNIT_TTESTSUITE_$__RUN$TTESTRESULT ()
> #20 0x00000007 in ?? ()
> #21 0xb7a7cb68 in ?? ()
> #22 0xb7a77808 in ?? ()
> #23 0x00000000 in ?? ()
> (gdb)
>
> -------------- Finish ----------------
>
> On 06/10/06, Vincent Snijders <[hidden email]> wrote:
>> Graeme Geldenhuys schreef:
>> > Oh, I forgot to mention.  If the ObjectStates match, the test passes
>> > fine, and doesn't give an access violation.
>> >
>> > While creating the new AssertEquals method, I purposefully created a
>> > failure with then gives the access violation, instead to the
>> > comparison message I expected:
>> >  "Failing on 1: Expected <posClean> but got <posEmpty>"
>> >
>>
>> Try creating a back trace, maybe that gives some insight.
>>
>> Vincent
>> _______________________________________________
>> fpc-pascal maillist  -  [hidden email]
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>>
>
>
> --
> There's no place like 127.0.0.1
>
>
> ------------------------------
>
> Message: 6
> Date: Fri, 06 Oct 2006 12:56:38 +0200
> From: TOUZEAU DAVID <[hidden email]>
> Subject: Re: [fpc-pascal] [libtar.pas]:Error: Illegal type conversion:
> "ShortString" to "^Char" without compilator options
> Cc: FPC-Pascal users discussions <[hidden email]>
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Many thanks Vincent
>
> the {$mode delphi} is a good way...
>
> Vincent Snijders a écrit :
>> TOUZEAU DAVID schreef:
>>> Dear
>>>
>>> I would like to use some units developped from delphi/klyx with
>>> Lazarus IDE On Linux.
>>>
>>> It seems that there is some differences between delphi/freepascal
>>> especially for longstring conversion.
>>>
>>> Many times, i received this compilator error :
>>>
>>> For example by using the LibTar.pas
>>> (http://www.destructor.de/libtar/index.htm)
>>>
>>> libtar.pas(355,8) Error: Illegal type conversion: "ShortString" to
>>> "^Char"
>>>
>>> i fixed this error with  {$H+}{$LongString On} tokens
>>>
>>> But is it this good way ??? is there an another solution ??
>>
>> An alternative is to add {$mode delphi} to the source file or compile
>> with -Sd compiler option.
>>
>> Vincent
>>
>
> --
>
> David Touzeau -------------------------- Linux Ubuntu Dapper 6.0.6
> FreePascal-Lazarus,perl,delphi,php icq:160018849
>
>
>
> ------------------------------
>
> Message: 7
> Date: Fri, 6 Oct 2006 06:26:48 -0500
> From: "Jeff Pohlmeyer" <[hidden email]>
> Subject: [fpc-pascal] RE: Get Local IP using glib (eth0,eth1)
> To: [hidden email]
> Cc: [hidden email]
> Message-ID:
> <[hidden email]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>> how can i list wich interface loaded without
>> need to parse /etc/networks/...?
>
>
>
> I would parse /proc/net/dev instead....
>
>
> program ifnames;
> var
>  s:shortstring;
>  f:text;
>  p:LongInt;
> begin
>  assign(f,'/proc/net/dev');
>  reset(f);
>  while not eof(f) do begin
>    readln(f,s);
>    p:=pos(':',s);
>    if ( p > 0 ) then begin
>      delete(s, p, 255);
>      while ( s <> '' ) and (s[1]=#32) do delete(s,1,1);
>      writeln(s);
>    end;
>  end;
>  close(f);
> end.
>
>
> ------------------------------
>
> Message: 8
> Date: Fri, 6 Oct 2006 13:30:16 +0200 (CEST)
> From: [hidden email] (Marco van de Voort)
> Subject: Re: [fpc-pascal] RE: Get Local IP using glib (eth0,eth1)
> To: FPC-Pascal users discussions <[hidden email]>
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset="US-ASCII"
>
>> I would parse /proc/net/dev instead....
>
> Better, but still Linux only. For a good solution, a resolver unit that
> accesses libc should be written that is portable (unlike the libc unit)
>
>
>
> ------------------------------
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
> End of fpc-pascal Digest, Vol 26, Issue 16
> ******************************************
>

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: low level disk access under Windows

Daniel Franzini

well

i did not wrote any code like this yet...but i do know that the so-called rawwrite tool used for writing images of boot floppies in windowz env is written in delphi (7 at the moment)...

since the sources are open you can browse around and see how things get done

http://www.chrysocome.net/rawwrite

On 10/6/06, Pianoman <[hidden email]> wrote:
        Hello, I'd like to ask if someone has experiences with low level
disk operations in windows with FPC.
The program should be able to copy entire diskete to one single image file
and for example extract a single file from that image or view its contents.

For example how can I read one sector from disk in to buffer?
Thanx for help
Pianoman



--
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'')
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal