From: Hemang L. <hl...@ci...> - 2006-01-31 13:30:22
|
Hi Andreas, I would also vote for fileutils namespace. Suggestions for few proc names are: getfile -> ::fileutil::read putfile -> ::fileutil::write appendto -> ::fileutil::append As others have mentioned, touch should not delete the file. Also, will it create the parent directory if it doesn't exist? I think it should. Hemang. Andreas Kupries wrote: > I have (over time) collected a set of convenient commands operating > on/with whole files which seem to belong directly into either the > fileutil namespace, or a related namespace, like 'fileutil::FOO'. > > Unfortunately I also have trouble to find a proper name for FOO. Note > that we also might wish to change their names when they go into their > namespace, to remove redundancies ('file'), or have their final names > reflect their behavior more correctly (touch, hack_file). > > Below are the commands collected so far. I would like to get opinions > on whether these commands should really be put into Tcllib, and if > yes, where. > > getfile PATH > > Returns contents of file. Assumes that file is text, > and in system encoding. > > I.e. loads the file completely into memory > > putfile PATH TEXT > > Writes text as the new content of the file. > Note: Does _not_ add a traling \n to the data. > > touch PATH > > Creates empty file at PATH. Deletes any pre-existing > file in this location. > > appendto PATH DATA > > See putfile, but appends the data to existing > content. Returns the location of the first character > of the appended data in the file. > > insertat PATH AT DATA > > Inserts data at offset AT into the file. > > removeat PATH AT N > > Removes N characters from the file, starting at > offset AT. > > hack_file PATH KEY VAL ... > > Takes the list of keys and values and applies them to > the contents of the file, via [string map]. > > hack_file_copy PATHin PATHout KEY VAL ... > > Like hack_file, but writes the result to a different > file. > > > |