Recent

Author Topic: Autopatch a set of files  (Read 4063 times)

Zath

  • Sr. Member
  • ****
  • Posts: 391
Autopatch a set of files
« on: September 14, 2012, 06:50:09 pm »
I've tried over the years to create a program with Delphi to autopatch a set of files that reside on a client pc. My ability to get this working is slim but I have the theory.
Can Lazarus be used to read files on a client pc, check if they are up to date and, if not, new or replacement files be installed from an ftp site accordingly ?

Other incarnations use a text file style list and it's compared with the main/current list online. It's read, and the required files downloaded.
The user runs a small shell program that basically calls the autopatch program, this concludes it's procedure, then the shell program goes on to execute the client software.

The software in question is a privately hosted game that has occasional updates of image files, sound files etc.
I had considered a php solution but recently found Lazarus and my pascal flame started to burn again. Trouble is, it's been so long since I did any programming on D3 and D5, I've lost what little knowledge I had.

I don't expect a fully fledged script (would be nice) but some guidance as how to go about creating it with Lazarus would be great.

Thanks.


gulyone

  • Guest
Re: Autopatch a set of files
« Reply #1 on: September 14, 2012, 07:48:30 pm »
nonblocking files transfers & communication components =

http://wiki.freepascal.org/lNet

blocking solution =

http://wiki.freepascal.org/synapse

using these sets of Components you can , with Lazarus and free pascal DO whatever you want and even more ... around the internet / intranet

as usually in a more elegant way and clean approach than many other languages like C

I suggest you to try synapse as a starting point to solve your problem
« Last Edit: September 14, 2012, 07:55:07 pm by gulyone »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8801
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Autopatch a set of files
« Reply #2 on: September 15, 2012, 05:09:49 am »
Could you pass UNC path of the file you want to update to the file handling routines to test? e.g.:
Code: [Select]
uses
  SysUtils;
begin
  WriteLn(FileSize('\\192.168.1.100\some\file\to\test'));
end.

Logic_Bomb

  • New Member
  • *
  • Posts: 41
Re: Autopatch a set of files
« Reply #3 on: September 27, 2012, 06:55:08 pm »
Two sets of data:
- MD5 Hashes of the Files Present on the Hard-Drive.
- MD5 Hashes of the Newest Updated Files.

Store the Hashes For the newest files on a web-server.
Use a networking library of your choice to query the web-server for the hashes of the newest files (Could be php or a simple txt).
Use an application on the local computer to compute the MD5 Hashes of the current files.
If NewHashes <> CurrentHashes then use a networking library of choice to download the new files and over-write the old ones.

Take a look at the FPGet example in the LNet Library and use the methodology shown in that example in conjunction with MD5Print(MD5File('Filename')) (MD5 Unit) to then create this.

Hope this is of some help as it is how I got an auto-updater for an application I made working. =)

Regards,

Logic_Bomb
« Last Edit: September 27, 2012, 06:59:51 pm by Logic_Bomb »

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Autopatch a set of files
« Reply #4 on: September 27, 2012, 07:03:19 pm »
Of course, it may be possible to refine the previous approaches to really patch parts of files instead of overwriting entire files.

This would mean having some kind of database/list with file versions, their (md5) hashes and patch files to go from that one to the latest one would be required, as would some binary patching mechanism...
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Zath

  • Sr. Member
  • ****
  • Posts: 391
Re: Autopatch a set of files
« Reply #5 on: October 15, 2012, 04:08:53 pm »
Thanks for the replies.
I've not been able to get on much to read and act on them.

 

TinyPortal © 2005-2018