04 March 2008, 09:43 | #1 |
Posts: n/a
|
Easiest way to insert a file into an ADF? (Delphi)
Hello!
I have a big problem. I need to insert a single file into an ADF with Delphi, as simple as possible. I've downloaded Big-Byte's ADF Toolkit from http://eab.abime.net/showpost.php?p=170677&postcount=2 but there is a problem: The file seems to be inserted and I can see it in the directory listing, but if I try to access it with Amiga or with ADFView, I get a "file not found" error. I've attached two ADFs, a working (inserted with ADFView) and the not working disk (with Big-Byte's code). Maybe someone can compare the files where the error is and maybe how I can fix it or at least a hint? My next idea was to use adflibd.dll from the Win32 console app of UnADF (ADFLib), I've checked http://lclevy.free.fr/adflib/api.html but this is a bit difficult in Delphi Is someone able to give me a hint how I can insert a file into an existing ADF with the help of this dll? As I am able to see, the necessary functions seem to be available in this dll file, but I have big problems to use them in Delphi. Or are there other alternatives, for example commando line commands for ADFView or something else? Can someone help me, somehow? Thank you |
06 March 2008, 16:10 | #2 |
Citizen of Elthesh
Join Date: Sep 2003
Location: UK
Posts: 949
|
The only thing "tricky" about ADFLib is that you have to open Device, Volume and finally File in the right order.
Unfortunately I don't have time to write a long explanation right now, but if you want to see a little example (albeit in C++), check out the source code of my Little Computer People serial number editor: http://eab.abime.net/showthread.php?p=275636#post275636 The source code is included in the archive. The interesting bits are in MainWindow.cpp, in particular under void MainWindow::open() and void MainWindow::save(QString fileName). The ADFLib functions all start with adf*, I think. This doesn't show how to insert a new file, but I think all you have to do is open a file with the right mode. Sorry, it's been a while since I looked at it. The ADFlib docs should tell, though. |
06 March 2008, 19:40 | #3 |
Posts: n/a
|
Thanks a lot, checked your source code, but, although it looks so simple, I am still not able to convert it to Delphi...
I need somehow to declare the necessary functions of this C++ dll in Delphi, so I could use them, but I am not able to translate them. The only thing I reached yet is to show version number and date... Code:
const adflib = 'adflibd.dll'; function adfGetVersionNumber(): PChar; external adflib; function adfGetVersionDate(): PChar; external adflib; procedure TForm1.FormCreate(Sender: TObject); begin Label1.Caption:=adfGetVersionNumber(); Label2.Caption:=adfGetVersionDate(); Label3.Caption:=adflib; end; Code:
struct Device* adfMountDev( char* name) |
07 March 2008, 18:56 | #4 |
Citizen of Elthesh
Join Date: Sep 2003
Location: UK
Posts: 949
|
The library itself is plain C and only uses plain C datatypes. My Pascal is a little shaky (haven't used it in years and years), so I'm not sure how to properly translate the prototype.
What I can tell you is that the Device pointer (Pascal has pointers and/or references too, right?) you get is just a handle, probably 32 bits (depending on what architecture the DLL was compiled for, but 32 bits are likely), and you only have to store it and pass it to the appropriate functions. The contents of the pointer are completely irrelevant to you and only matter to the library, so I assume any datatype with the right size will do (maybe a 32-bit integer type). As for the name parameter, that's a plain C string (address of a character array), which may be tricky because Pascal (as far as I remember) stores strings differently than C. While C stores them \0 (null character) terminated, Pascal (again, as far as I remember) prefixes them with their length instead. I'm sure if you look up general information about accessing C libraries from Pascal that problem will be addressed, though. Edit: I reformulated some things after thinking after writing. Last edited by eLowar; 07 March 2008 at 19:08. Reason: Clarified some things. |
07 March 2008, 20:49 | #5 |
Registered User
Join Date: Dec 2007
Location: Sweden
Posts: 33
|
PChar is the Pascal pointer-to-char, if I recall correctly. You could translate the header files, I'm sure there exists a tool for this problem.
|
26 March 2008, 22:37 | #6 |
Junior Member
Join Date: Apr 2002
Location: Germany
Posts: 103
|
Hopefully I could help a little bit... |
25 April 2008, 21:29 | #7 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
|
Hey, a Delphi programmer! Good man.
Looked at elowar's thread for 5 seconds, didn't find a link to the c source or a snippet, otherwise I could help - I've had to learn a bit of c to get going on the gp2x. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Fastest,Easiest,Cheapest way to transfer adf images between PC and Amiga(mostly 500) | ikonsgr | support.Hardware | 129 | 14 September 2017 10:08 |
ADF File Comparison | Radertified | request.Apps | 17 | 29 July 2013 00:50 |
Command line tool to insert files into an ADF? | cdoty | Coders. General | 1 | 07 December 2009 10:53 |
Copy CF card file to ram:, insert other CF card, copy over? | Photon | support.Hardware | 16 | 21 July 2009 22:05 |
Running non .adf file, .info file?? | ypestis | New to Emulation or Amiga scene | 5 | 29 March 2006 18:53 |
|
|