![]() It is highly recommended to use the two-parameter version of (DiskFileName, ArchiveFileName) with ArchivefileName = DiskFileName because this procedure automatically replaces the path delimiters as required. ![]() It will unzip correctly on Windows, but not on Linux where the backslash is considered to be a valid file name character. Therefore, such a zip file will contain backslashes on Windows. This is important for the one-parameter overload of (DiskfileName) which simply assume the archived file name to be equal to the DiskFileName, without any adaptions. Specification of the zip format requires that forward slashes (' /') are used even in case of Windows. Free end end end Īnother restriction is the path delimiter in the archived file name. ZipAllFiles Result := true finally OurZipper. Free end // Execute zipping action and create zip file OurZipper. AddFileEntry ( diskFileName, archiveFileName ) end finally list. archiveFileName := StringReplace ( list, ADirectory, '', ) archiveFileName := UTF8ToCP437 ( archiveFileName ) OurZipper. Count - 1 do begin // Name of the file to be zipped on disk diskFileName := list // Name of the file to be zipped in the archive: we remove the // common path and thus make the files relative to the directory // into which they will be unzipped later. FindAllFiles ( list, ADirectory, AMask, IncludingSubDirs ) for i := 0 to list. Create try // List all files in ADirectory and, if required, its sub-directories. FileName := AZipFileName list := TStringList. Uses FileUtil, LConvEncoding, LazUTF8, Zipper function PackFiles ( AZipFilename, ADirectory, AMask : String IncludingSubdirs : Boolean ) : Boolean var OurZipper : TZipper list : TStringList i : Integer diskFileName, archiveFileName : String begin Result := false if AMask = '' then AMask := '*.*' ADirectory := IncludeTrailingPathDelimiter ( ADirectory ) if DirectoryExists ( ADirectory ) then begin OurZipper := TZipper. Here is the adaption of above example for an FPC version before 3.2: Note also that the DiskFileName must have the encoding required by the operating system, otherwise the file will not be found for zipping in case of FPC before 3.0 this may require another code page conversion. If your FPC is older than v3.2 you must convert the ArchiveFileName argument to CP437 - of course, this is not possible for all characters, and thus you must be very careful with zipper in this case. UseLanguageEncoding := true // Requires FPC 3.2+ // create and write the zip file OurZipper. UTF8 encoding is written when UseLanguageEncoding is true. ![]() Free end // By default zipper writes file names in encoding of the IBM PC, CP437. We remove the deirectory from the archiveFileName := StringReplace ( diskFileName, ADirectory, '', ) // Store these filenames for the zipper OurZipper. Count - 1 do begin // diskfilename is the name of the file to be zipped on the disk diskFileName := list // archivefilename is the name of the file to be zipped as it appears // in the zip. When IncludingSubDirs is true the search continues recursively in // the subdirectories. '*.*') // found in the given directory to the provided list. Create try // FindAllFiles adds all file names matching the mask (e.g. FileName := AZipFileName // Read names of the files contained in ADirectory to a stringlist list := TStringList. Create try // Set the name of the zip file to be created OurZipper. So I decided to use my preferred SEO tool Screaming Frog and I crawled the site of one of the most influential marketing and web marketing person: sir Seth Godin, yes the father of the Permission Marketing.Uses FileUtil, zipper function PackFiles ( AZipFilename, ADirectory, AMask : String IncludingSubDirs : Boolean ) : Boolean var OurZipper : TZipper list : TStringList i : Integer diskFileName, archiveFileName : String begin Result := false ADirectory := IncludeTrailingPathDelimiter ( ADirectory ) if DirectoryExists ( ADirectory ) then begin OurZipper := TZipper. 100 words, 200 words, 1200 characters? What is the best length? ![]() Every day some tools publish some blog posts about the average length of the page with good search engine rankings. Every day someone writes a blog post about how long the content of webpages needs to be, overall for SEO reasons. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |