Tar Library

User contributed sources that have become inactive, deprecated, or generally unusable. But ... we don't really want to throw them away either.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Tar Library

Post by bcohio2001 »

Considering this a project at the moment. If it leads to being moved to the "Library" section of the forum remains to be seen.

TarLib - 00-01-00.zip
http://www.mediafire.com/?mehthgru15jv1mm
TarLib - 00-01-00.tar (This file was created by the library. Sorry, do not have gzip capabilities. But do have 7z, should have used that.)
http://www.mediafire.com/?lr4klg57039uprr

Comments, questions and TESTING are welcome.
Look at included text files for more information.

Feel free to contact me at yahoo.com (same username).
Please include 'TarLib' in the subject line.
Last edited by bcohio2001 on May 27, 2014 19:24, edited 2 times in total.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Tar Library

Post by bcohio2001 »

Version 0.2 -- Nov. 30, 2013
Added: Internal function to add 'padding'. Returns number of bytes written.
Added: Defined TarLib_Major, TarLib_Minor and TarLib_Patch.
Added: User functions TarValidate, DeleteCurrentEntry, GetTarLib_Major, GetTarLib_Minor and GetTarLib_Patch.
Added: When closing a 'modified' archive. Scans for needed and unused folder entries. Adds the needed and removes the unused.
Added: Test for platform by checking "HOME" environment variable, not a 'normal' MS setting. Startings of cross platform compatibility.
Added: A STUBBED internal LINUX_Dir() function.

Fixed: Changed WriteLongName from a internal sub to a internal function that returns number of bytes written.
Fixed: File entry's "Version" was incorrectly written as double null. Should have been double zero.
Fixed: Internal sub 'MapDel'.

Change: Renamed user function Extract to a 'clearer' ExtractCurrentEntry.
Change: Return values AddFile and AddFolder were changed, refer to file "Tar.txt" in the Docs folder.

The files in the download have been better organized. All programs in the 'Sample' folder reference files on my system and need to be changed to use.
http://www.mediafire.com/download/yi7ub ... -02-00.zip
http://www.mediafire.com/download/eniht ... -00.tar.gz <-- Completely created and updated by using the library. In 'Samples' look at "UpdateMe.bas"
Last edited by bcohio2001 on Mar 04, 2014 13:31, edited 1 time in total.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Tar Library Fixes coming

Post by bcohio2001 »

While implementing into a larger program found some issues.

Unable to compare entry's type to a 'known' one.
Quick fix: In TarLib.bi add at the end.

Code: Select all

'LF_ constants represent the "type" of an entry
'Normal file type.
#Define LF_NORMAL Asc("0")
'Directory file type.
#Define LF_DIR Asc("5")
Other issues:
1. Export GetRootPath and GetPathPrefix for user.
2. Modify ExtractCurrentEntry to extract ALL entries within a given folder.
3. Modify DeleteCurrentEntry to delete ALL entries within a given folder.

RENAMES NEEDED!!!!! (Taken from FBEdit output screen.)
./libTar.a(Tar.o):fake:(.text+0x0): multiple definition of `DW_DIR@4'
FbTemp.o:fake:(.text+0x19810): first defined here
./libTar.a(Tar.o):fake:(.text+0x290): multiple definition of `STR_REPLACEANY@12'
FbTemp.o:fake:(.text+0x22f10): first defined here
./libTar.a(Tar.o):fake:(.text+0x3c0): multiple definition of `STR_REMOVE@8'
FbTemp.o:fake:(.text+0x230e0): first defined here
./libTar.a(Tar.o):fake:(.text+0x4d0): multiple definition of `HSTRIPFILEPATH@4'
FbTemp.o:fake:(.text+0x219c0): first defined here
./libTar.a(Tar.o):fake:(.text+0x590): multiple definition of `HFILEPATH@4'
FbTemp.o:fake:(.text+0x21910): first defined here
./libTar.a(Tar.o):fake:(.text+0x640): multiple definition of `DEBUGFILE@8'
FbTemp.o:fake:(.text+0x710): first defined here
./libTar.a(Tar.o):fake:(.text+0x1420): multiple definition of `FT2DBL@4'
FbTemp.o:fake:(.text+0xf730): first defined here

I thought that since 'inside' a library and not available to 'general public' would not be an issue. Notice the word 'assume' was not used.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Tar Library

Post by bcohio2001 »

Version 0.2.1 -- Feb. 08, 2014
Added:
--- Exported functions GetRootPath and GetPathPrefix for user.
--- Defines for common file types in TarLib.bi
--- User function Entry_GetModeStr to return the entry's mode flags as a string. (Adding this is not enough to up this to Ver. 0.3)
--- Seperate program "WinTar". Good test for this library, allows MS users to create and update tar files.

Changed:
--- Names of some functions and subs in Misc.bi because of conflict with a larger project.
--- Modified ExtractCurrentEntry to extract ALL entries within a given folder.
----- Added NewName and Prefix parameters.
--- Commented out a lot of "debugging" comments to the TarLib-Trace log file.
----- Unless error occurs should not have any.

TODO:
--- Linux compatablity.
--- Allow user to change each mode flag. This is really only relevant to Linux systems.
--- Work in GNU types. Extended headers and sparse files. Etc.
--- Rename files inside tar file.

http://www.mediafire.com/download/8hxkq ... -01.tar.gz
http://www.mediafire.com/download/17hqb ... -02-01.zip

Announcing WinTar
http://www.mediafire.com/download/abl5v ... WinTar.zip
Last edited by bcohio2001 on Mar 04, 2014 13:33, edited 1 time in total.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Tar Library

Post by bcohio2001 »

Version 0.2.2 -- Feb. 23, 2014
Fix:
--- Set SystemPathSep at compile time via #Define, now a shared string set at run time.

TODO:
--- Linux compatibility.
--- Allow user to change each mode flag. This is really only relevant to Linux systems.
--- Work in GNU types. Extended headers and sparse files. Etc.
--- Rename files inside tar file.
http://www.mediafire.com/download/952lm ... -02-02.zip
*Edit: On March 3rd, I found that the tar file was corrupt.*
http://www.mediafire.com/download/18gpb ... -02.tar.gz

WinTar:
Version 1.0.1 -- Feb. 23, 2014
--- Update due to fix in TarLib. No code changes.
http://www.mediafire.com/download/0fy9u ... .00.01.zip
Last edited by bcohio2001 on Mar 14, 2014 13:11, edited 1 time in total.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Tar Library

Post by bcohio2001 »

Argh! On March 3rd, as stated in above post, found that the 'tar' file of 'TarLib--00.02.02' was corrupt. The zip file is fine.
And since now working on V0.3 do not have original files.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Tar Library

Post by bcohio2001 »

Version 0.3.0 -- Mar. 14, 2014 (Pi day!)
Added:
--- Internal function to create a temp file name to use in user's temporary folder.
--- Create backups of file before any changes.
------ Get_NumBackups, UndoChange and UndoAllChange functions.
------ ClearBackups sub.
--- Renaming of files and folders in a tar file.

Fixes:
--- Better(?) handling of LongNames. (At this time, have not encountered any. So is all theoretical.)
--- Various minor fixes.

TODO/Wish list:
--- Change many, if not all UByte ptrs to Strings or ZString Ptrs.
--- Linux compatibility. (I really need help here!)
--- Allow user to change each mode flag. This is really only relevant to Linux systems.
--- Work in GNU types. Extended headers and sparse files. Etc.
--- Copy from one tar file to another.

http://www.mediafire.com/download/z2r5i ... -00.tar.gz
http://www.mediafire.com/download/s4c84 ... -03-00.zip
Last edited by bcohio2001 on May 27, 2014 19:22, edited 1 time in total.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Tar Library

Post by bcohio2001 »

Version 0.4.0 -- May 27, 2014
Changes:
--- Upon closing of file, no longer remove empty folder entries. (Commented out)
--- Minimal GNUTar support. (Longname and LongLinkname)
--- Moved some internal functions and subs into their respective types (classes).
--- Backups are temporarily disabled for now, until a better system can be created.
----- With rapidly changing file, will not keep up accuratly. (Disk caching)
--- Changed remaining UByte ptrs to Strings in types.

Added:
--- Allow user to change each mode flag. (This is really only relevant to Linux systems.)
--- Support for extended headers.
----- Allow saving of create and last access times of file into archive.
----- Removed fuction WriteLongName and incorporated into new function WriteXHeader.
--- Create empty folder entry.
--- Reading of Joerg Schilling's star implementation.

Fixes:
--- Even better(?) handling of long entry names.
----- At this time, have not encountered any. So is all theoretical.

TODO/Wish list:
--- Continue to add more support for GNUTar, sparse files.
--- Add support for Solaris, Apple's Mac OS X.
--- Linux compatibility. (I really need help here!)
----- Get user and group info.
----- Get file's create and last access times.
--- Copy from one tar file to another.

Library and sample programs:
http://www.mediafire.com/download/268ii ... -04-00.zip
http://www.mediafire.com/download/myw2v ... -00.tar.gz

Source code:
http://www.mediafire.com/download/c7k7s ... Source.zip
http://www.mediafire.com/download/k7xb7 ... rce.tar.gz
Last edited by bcohio2001 on Aug 12, 2014 21:54, edited 1 time in total.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Tar Library

Post by bcohio2001 »

Version 0.5.0 -- Aug. 12, 2014
Added:
-- Support for reading GNUTar sparse '0.1' version files.
-- Reading and writing of GNUTar sparse '1.0' version files.
-- SparseOn() sub.
-- PutAllTimes() sub.
---- The access and modified times of the file will be changed upon extraction, if available in archive.
-- Linux compatibility.
-- ToggleUseFileUserInfo() sub (only relevent for Linux systems).
---- When adding file will use actual file's user/group info instead of current users info.
---- Upon extraction, not implimented, as yet.

Changes:
-- Re-enabled backups.
-- Renamed sub SaveAllTimes to clearer GetAllTimes.

TODO/Wish list:
--- Add support for Solaris and Apple's Mac OS X.
--- Copy from one tar file to another.

Library and example programs:
http://www.mediafire.com/download/fbbuz ... -05-00.zip
http://www.mediafire.com/download/bg52f ... -00.tar.gz

Source code:
http://www.mediafire.com/download/cnmi9 ... Source.zip
http://www.mediafire.com/download/4c844 ... rce.tar.gz
Last edited by bcohio2001 on Apr 06, 2015 19:16, edited 1 time in total.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Tar Library

Post by bcohio2001 »

Version 0.6.0 -- Apr. 06, 2015
Added:
-- User function Entry_GetUsedSize
---- Returns total used size of entry in archive.
---- (Was only reason for unreleased 0.5.1)
-- User functions Copy2TarByIdx and Copy2TarByName
---- To copy entries from one archive to another
-- User sub PreserveAccessTimes
---- To keep local access times same when adding files to archive.
-- User subs SetAddOption and SetExtractOption
---- What to do if file exists in archive AND on system.
-- User sub Toggle_FileBackups
---- Turns on or off background backups of current archive.
-- "Support" for Linux 'linked' files.
---- ALL CODE DEALING WITH LINKS HAVE NOT BEEN TESTED!
---- Windows has a 'plug-in?' to create Symbolic links, but not with 'normal' set up.
-- User sub SetReportVerbose
---- Prints to screen certain events.
-- User function GetEntryCountOnOpen
---- returns count of entries upon opening of archive.
---- current count retrieved by the Entry_GetCount function
-- User function GetEntriesAdded
---- Count of number of entries added to archive.
-- User function GetEntriesDeleted
---- Count of number of entries removed from archive.
-- User function GetEntriesUpdated
---- Count of number of entries updated in archive.

Change:
-- TarOpen function: the CreateFlag (second praram) is ignored.
---- And will be removed totally or assigned different use in a later release.
-- Freebasic > 1.00 allowing variable length UDT String arrays.
---- Modified storage of backup file names to regular string array.
-- File dates and times are now only changed to a 'Double' when needed.
---- Stored as 'LTime', my implentation of Linux's 'timespec'. Which is the standard for tar.

Fix:
-- The original source, do not have anymore or where it came from, gave 'magic' mode number for folder and file entries.
---- The magic number for a folder was 1003 decimal. WRONG!

Library and sample code:
http://www.mediafire.com/download/x8356 ... -06-00.zip
http://www.mediafire.com/download/yar3q ... -00.tar.gz
Source code:
http://www.mediafire.com/download/pfdaj ... rce.tar.gz
http://www.mediafire.com/download/s0v87 ... Source.zip
Last edited by bcohio2001 on May 16, 2015 15:11, edited 1 time in total.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Tar Library

Post by bcohio2001 »

Version 0.6.1 -- May 16, 2015
Fix:
-- Incorrect file datetime stamps returned.

Source files:
http://www.mediafire.com/download/8vstw ... Source.zip
http://www.mediafire.com/download/izyp2 ... Source.tar
http://www.mediafire.com/download/s8h3o ... rce.tar.gz

Library and example programs:
http://www.mediafire.com/download/51msh ... -06-01.zip
http://www.mediafire.com/download/rrb80 ... -06-01.tar
http://www.mediafire.com/download/w8t7j ... -01.tar.gz
(7z is not recognizing gz files created by zlib on my system so uploading regular tar files.)
Last edited by bcohio2001 on Sep 27, 2015 14:12, edited 1 time in total.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Tar Library

Post by bcohio2001 »

Version 0.7.0 -- Sept. 27, 2015
Fix:
-- Debuging code removed, left over from the 0.6.1 version.
-- Sub TarClose nullifies user's file pointer.
-- Function WriteEntry now writes any entry passed, and is now part of the TarFile type definition.
-- Files can be extracted with original achived time.
-- Updating linked files fix.
-- Null TarFile pointer checks.

Removed:
-- User sub Entry_SetName.
-- Sub SkipEntry no longer available to user.
-- User sub SetReportVerbose in favor of TarMsgs.

Added:
-- Type TarMsgs for event reporting.
---- Must be 'setup' before opening files.
-- Added TarLib_Loaded define to TarLib.bi.
-- User function ExtractAll
-- TimeStamp options enabled.

Change:
-- TarOpen function
---- Optional second parameter is a TarMsgs pointer, was Integer.
-- Implemented 'pheader' type to control all headers
-- Functions DeleteCurrentEntry, RenameCurrentEntry, AddFile and AddFolder MAY nullify user file pointer on major error.

Source:
http://www.mediafire.com/download/qjxkd ... Source.zip
http://www.mediafire.com/download/fmbzj ... rce.tar.gz
Library and few examples:
http://www.mediafire.com/download/8rvgo ... -07-00.zip
http://www.mediafire.com/download/wyq5e ... -00.tar.gz
Last edited by bcohio2001 on Jul 09, 2016 14:28, edited 1 time in total.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Tar Library

Post by bcohio2001 »

Version 0.7.1 -- July 09, 2016
Code maintenance:
-- Renamed and reworked header reading and writing.
-- File entry numerical data is specified as 'Long', was Integer, to ensure 32 bit data stored. Except for FSize which is still LongInt.
-- Type vars clarification:
---- 'Entry' has 'As pheader Header', and 'pheader' had 'As UByte Ptr Header' which is now 'HBuffer'. (Reference as Entry.Header.Header[x] confusing)

Fix:
-- Entry.CanSparse() was never fully enabled.
-- Renaming of sparsed file.
-- In Copy2TarByName() and Copy2TarByIdx() functions, copied file was not named correctly.

Added:
-- Check to see if source file has entries to copy in Copy2TarByName() and Copy2TarByIdx() functions.
-- TarClose() deletes file if no data.

Source:
http://www.mediafire.com/download/raott ... Source.zip
http://www.mediafire.com/download/k4nt2 ... rce.tar.gz
Library and a few examples:
http://www.mediafire.com/download/a5sss ... -07-01.zip
http://www.mediafire.com/download/k0k4c ... -01.tar.gz

This will probably be the last update. Although there seems to be interest, by checking the number of downloads at Mediafire, I have not received any feedback, comments etc. I have been the one to find ALL mistakes. AND DON'T EVEN NEED TO USE IT.
Last edited by bcohio2001 on Dec 10, 2018 4:02, edited 1 time in total.
St_W
Posts: 1618
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Tar Library

Post by St_W »

I haven't needed TAR packages in FreeBasic yet, but if I would I'm sure this is a great library.
I'd suggest putting the code on some open source software platform like Github so that the code stays available and others could continue working on it (and send pull requests). You can also publish (binary) release packages there (there's a separate upload function for that; don't put it in the source code repository).
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Tar Library

Post by bcohio2001 »

It's been a while..... I have done a lot of updating to code, but falling short.

I am now officially requesting help from someone who is more versed in Linux coding. I want to put this into a repository, but have no experience in it.
So if someone wants to take over and run with this....GO FOR IT.

Source code:
http://www.mediafire.com/file/xtilnad66 ... Source.zip
Test code, valid for version 0.7.1
http://www.mediafire.com/file/mg2pk00rn ... t_Code.zip
Obsolete code, notes
http://www.mediafire.com/file/723r4rb0u ... e_code.zip
Last edited by bcohio2001 on Dec 10, 2018 4:03, edited 1 time in total.
Post Reply