<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LMD Innovative Blog &#187; Tutorials</title>
	<atom:link href="http://blog.lmd.de/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.lmd.de</link>
	<description>News, Tutorials</description>
	<lastBuildDate>Mon, 16 Jan 2012 18:38:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Download a specific file from a ZIP using TLMDWebHTTPGet</title>
		<link>http://blog.lmd.de/2009/10/using-tlmdwebhttpget-to-downloading-specified-file-from-zip/</link>
		<comments>http://blog.lmd.de/2009/10/using-tlmdwebhttpget-to-downloading-specified-file-from-zip/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 00:12:53 +0000</pubDate>
		<dc:creator>Alexander</dc:creator>
				<category><![CDATA[LMD Packs]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WebPack]]></category>
		<category><![CDATA[zip]]></category>

		<guid isPermaLink="false">http://blog.lmd.de/?p=8</guid>
		<description><![CDATA[From the most recent version of LMD WebPack on the TLMDWebHTTPGet control is able to resume file downloads from a specified position. 2 new properties were added: RangeStart and RangeEnd. Thus a programmer can setwith RangeStart position from which downloading should be started, whereby RangeEnd specifies end position. Another property is Resume: If set to [...]]]></description>
			<content:encoded><![CDATA[<p>From the most recent version of LMD WebPack on the TLMDWebHTTPGet control is able to resume file downloads from a specified position. 2 new properties were added: RangeStart and RangeEnd. Thus a programmer can setwith RangeStart position from which downloading should be started, whereby RangeEnd specifies end position. Another property is Resume: If set to true, the component will search in TLMDWebHTTPGet.DownloadDir for a file named with TLMDWebHTTPGet.DestinationName and fills RangeStart property automatically with the found file size.</p>
<p><span id="more-8"></span></p>
<p>So how can a programmer use described features? Possibilities are endless:</p>
<ol>
<li>Download a filelist and get a specified file from zip file only</li>
<li>Multi-threaded file downloads</li>
<li>Allow end-users to pause/resume downloads of large files</li>
</ol>
<p>Here is simple code to implement first example (downloading a specified file from zip):</p>
<pre class="brush:delphi">  LMDWebHTTPGet1.URL := 'http://www.lmd.de/downloads/lmd2010vcl/setupse10d14.zip';
  // "end of central directory" size.
  // Minus shows that we read it from end of file
  LMDWebHTTPGet1.RangeEnd := -17;
  // Downloads last 17 bytes of file
  if LMDWebHTTPGet1.Process(False, False) then
  begin
    LEndOfCentralRecord.LoadFromStream(LMDWebHTTPGet1.Data);
    // Fills RangeStart by "Central Directory" structure begin offset
    LMDWebHTTPGet1.RangeStart := LEndOfCentralRecord.OffsetOfCentralDirectory;
    LMDWebHTTPGet1.RangeEnd := LMDWeHTTPGet1.RangeStart + LEndOfCentralRecord.SizeOfCentralDirectory;
    // Downloads "Central Directory" structure
    if LMDWebHTTPGet1.Process(False, False) then
    begin
      LCentralDirectory.LoadFromStream(LMDWebHTTPGet1.Data);
      // Fills RangeStart by offset of compressed file in ZIP
      LMDWebHTTPGet1.RangeStart := LCentralDirectory.Files['readme.txt'].FileOffset;
      // Compressed size
      LMDWebHTTPGet1.RangeEnd := LMDWebHTTPGet1.RangeStart + LCentralDirectory.Files['readme.txt'].CompressedSize;
      // Downloads compressed file "readme.txt"
      if LMDWebHTTPGet1.Process(False, False) then
      begin
        // Processing of compressed file
      end;
    end;
  end;</pre>
<p>LEndOfCentralRecord, LCentralDirectory are placeholders that schematically shows corresponding zip format structures &#8211; &#8220;Central directory structure&#8221; and &#8220;End of central directory record&#8221;. The full specification is described <a href="http://blog.lmd.de/xT" target="_blank">here</a>.</p>
<p>Besides that WebPack includes a demo project in <code>demos\lmdweb\LMDWebHTTPGetResume</code> folder.</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://blog.lmd.de/2009/10/using-tlmdwebhttpget-to-downloading-specified-file-from-zip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

