Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.1.4

Request #13842 Get which were the files affected by the replacement
Submitted: 2008-05-06 13:36 UTC
From: darizotas Assigned:
Status: Open Package: File_SearchReplace (version 1.1.2)
PHP Version: 5.2.5 OS: Windows XP SP2
Roadmaps: (Not assigned)    
Subscription  


 [2008-05-06 13:36 UTC] darizotas (Dario Borreguero)
Description: ------------ Create a new method like getNumOcurrences. This method would return a map containing for each file where the needle was found, the number of replacements (ocurrences). Regards, DarĂ­o.

Comments

 [2008-05-10 12:38 UTC] doconnor (Daniel O'Connor)
Hey Dario, Any chance of creating a small script which demonstrates how this would be used / what the current api can't do? For those of us not familiar with the package, that'd be a great help...
 [2008-05-11 16:03 UTC] techtonik (anatoly techtonik)
This can be used in user interface to display result of the replace operation. As recorded in bug #2707 current API lacks search, "preview" or "dry run" option which would be able to supply this information without doing replacement. It might be possible to provide method to collect the number of replacements after operation for each file, but getting needle positions after operation doesn't make sense to me. There was a proposal for File_SearchReplace2 package where only search functionality could be implemented, but it was rejected. http://pear.php.net/pepr/pepr-proposal-show.php?id=281
 [2008-05-12 07:10 UTC] darizotas (Dario Borreguero)
Sorry Anatoly, I think that I've expressed very badly, I didn't mean to find the exact position of the needle in each affected file. I'm only interested in knowing the name of the file, where it was replaced, and the number of ocurrences in that file. This is almost already done in doFiles and doDirectories. For example, instead of saving the ocurrences: [504 and 470] $this->ocurrences += $newfile[0]; could be [504] $this->ocurrences[] = array($this->directories[$i].file, $newfile[0]); [470] $this->ocurrences[] = array($this->files[i], $newfile[0]); Of course, this requires to change the method getNumOcurrences. I hope I've expressed better the idea this time. Regards, Dario.