Ticket #23 (closed enhancement: fixed)

Opened 3 years ago

Last modified 8 months ago

Concat two or more files into one.

Reported by: norman@sefiroth.de Assigned to: mrook
Priority: minor Milestone: 2.2.0
Component: Version: 2.2.0RC1
Keywords: concat files copy merge Cc:

Description

I like to have a task like the concat task in ANT, so you can merge to or more files into a single new file.

Attachments

FileUtils.php (11.8 kB) - added by norman@sefiroth.de on 03/30/06 10:17:37.
defaults.properties (2.5 kB) - added by norman@sefiroth.de on 03/30/06 10:18:11.
ConcatTask.php (10.9 kB) - added by anonymous on 03/30/06 10:18:28.
FileSystem.php (23.3 kB) - added by norman@sefiroth.de on 03/30/06 10:19:08.
FileSystem.2.php (23.3 kB) - added by norman@sefiroth.de on 03/30/06 10:19:43.
PhingFile.php (32.2 kB) - added by norman@sefiroth.de on 03/30/06 10:20:18.
ABO.txt (52 bytes) - added by anonymous on 04/28/08 06:10:32.

Change History

03/30/06 09:54:29 changed by norman@sefiroth.de

I hacked a little bit on the source my self. And make a more or less working concat task out of the copy task. Therefore I changed FileSystem.php, PhingFile.php, FileUtils.php and default.properties and added a modified version of CopyTask.php as ConcatTask.php. If this might be useful, I could publish my changes. - If so, please tell me how.

03/30/06 09:57:32 changed by mrook

  • owner set to mrook.
  • priority changed from major to minor.
  • version deleted.
  • status changed from new to assigned.
  • milestone changed from 2.2.0 to 2.3.0.

Hi Norman,

You can attach the changed files, or preferably a diff against the latest trunk version.

03/30/06 10:17:37 changed by norman@sefiroth.de

  • attachment FileUtils.php added.

03/30/06 10:18:11 changed by norman@sefiroth.de

  • attachment defaults.properties added.

03/30/06 10:18:28 changed by anonymous

  • attachment ConcatTask.php added.

03/30/06 10:19:08 changed by norman@sefiroth.de

  • attachment FileSystem.php added.

03/30/06 10:19:43 changed by norman@sefiroth.de

  • attachment FileSystem.2.php added.

03/30/06 10:20:18 changed by norman@sefiroth.de

  • attachment PhingFile.php added.

03/30/06 10:21:49 changed by norman@sefiroth.de

Sorry, no diff on my current machine :( And FileSystem.2.php is just the same as FileSystem.php ... But I can't remove that :(

03/30/06 12:25:30 changed by hans

Is this something that the [built-in] AppendTask was unable to do? (http://phing.info/docs/guide/current/chapters/appendixes/AppendixB-CoreTasks.html#AppendTask) It seems from the description like these are at least very similar in functionality.

03/30/06 12:43:00 changed by norman@sefiroth.de

  • version set to 2.2.0RC1.

Well, ANT call it concat and not append.

The main differences are: - concat will append to an existing file, if parameter append is set to true. (append="no" is default). If it is set to append to "no" it will allways create a new, fresh destfile. - it is called "destfile" not "destFile" as parameter name in ANT ;-) - it has a force parameter to disable update checking, so it will concat files even when the destfile is newer. - in ANT you can even concat binary files with this.

For my use, I could do it this way <delete file="tmp.tmp"/> <append destFile="tmp.tmp"> ... </append>

okay, but maybe we could make a

<concat destfile="tmp.tmp" force="true"> ... </concat>

out of it and make PHing looks a little bit more than ANT. But that is just my opinion.

BTW: I like PHing, because I am a Java programmer who has to use PHP for a project, and PHing make me feel like home when I do PHP ...

03/30/06 13:27:12 changed by anonymous

It looks, then, like we could make Append behave like Concat with the single addition of a "force" parameter.

Currently:

  1. Yes, AppendTask will always append to the file (not overwrite it)
  2. destfile & destFile are the same for Phing (parameters attributes not case-sensitive)
  3. AppendTask should work fine for binary files too.

So, am I write in assuming that adding a "force" attribute would fully address this need?

BTW, I created the AppendTask based on needs & didn't realize that Ant had a Concat task at the time. :) Since then things have been added to AppendTask, but also based on user needs & not so much with a desire to match the API of ConcatTask.

03/30/06 14:35:11 changed by norman@sefiroth.de

Okay for me, and maybe you can add a real concat in 2.3.0 ;-)

BTW: I looked in the ANT documentation frist, find concat and did not search for the AppendTask ... shame on me ... B-) But I needed a concat/append task so badly, and I have got the ANT documentation as a paper version ...

The point with "binary" parameter is: If you concat/copy it with "binary" as a flag, it won't change cr/lf lf or cr characters. So you can copy/concat unix style files on a windows system without converting them into a windows sytle file...

03/30/06 15:51:14 changed by hans

Ok, we can also just add an alias for "concat" to point to the AppendTask to help people out. Append also supports things like filesets and filelists in addition to appending with CDATA and single files.

I don't know how that "binary" issue would translate into the PHP world. I don't believe PHP will translate the CR/LF characters either. There is a "binery" flag that needs to be passed to fopen() on Windows, but AFAIK Phing already does this for every file by default (in the FileReader/FileWriter stuff). Did you have to make a change to the File classes to support this? (and was it not working as desired before?)

03/30/06 16:37:38 changed by norman@sefiroth.de

Well, an alias will do it for now, I think. - But concat has normaly the opposit default settings as the append task.

Because I don't use the binary parameter, this can be left out anyway.

I think you can close this ticket as soon as the alias is inserted.

Thanks,

Norman

08/10/06 09:54:45 changed by mrook

  • milestone changed from 2.3.0 to 2.2.0.

Moving this to milestone 2.2.0.

08/10/06 09:55:28 changed by mrook

  • status changed from assigned to closed.
  • resolution set to fixed.

Alias 'concat' added in changeset:105.

04/28/08 06:10:32 changed by anonymous

  • attachment ABO.txt added.

Add/Change #23 (Concat two or more files into one.)




Action