\JFilesystemPatcher
A Unified Diff Format Patcher class
Synopsis
class JFilesystemPatcher
{
- // constants
- const SRC_FILE = '/^---\\s+(\\S+)\s+\\d{1,4}-\\d{1,2}-\\d{1,2}\\s+\\d{1,2}:\\d{1,2}:\\d{1,2}(\\.\\d+)?\\s+(\+|-)\\d{4}/A';
- const DST_FILE = '/^\\+\\+\\+\\s+(\\S+)\s+\\d{1,4}-\\d{1,2}-\\d{1,2}\\s+\\d{1,2}:\\d{1,2}:\\d{1,2}(\\.\\d+)?\\s+(\+|-)\\d{4}/A';
- const HUNK = '/@@ -(\\d+)(,(\\d+))?\\s+\\+(\\d+)(,(\\d+))?\\s+@@($)/A';
- const SPLIT = '/(\r\n)|(\r)|(\n)/';
- // members
- protected $sources;
- protected $destinations;
- protected $removals;
- protected $patches;
- protected $instance;
- // methods
- protected void __construct()
- public static JFilesystemPatcher getInstance()
- public JFilesystemPatcher reset()
- public integer apply()
- public JFilesystemPatch addFile()
- public JFilesystemPatch add()
- protected static array splitLines()
- protected static boolean findHeader()
- protected static boolean findHunk()
- protected void applyHunk()
- protected array getSource()
- protected array getDestination()
Constants
Name | Value |
---|---|
SRC_FILE | '/^---\\s+(\\S+)\s+\\d{1,4}-\\d{1,2}-\\d{1,2}\\s+\\d{1,2}:\\d{1,2}:\\d{1,2}(\\.\\d+)?\\s+(\+|-)\\d{4}/A' |
DST_FILE | '/^\\+\\+\\+\\s+(\\S+)\s+\\d{1,4}-\\d{1,2}-\\d{1,2}\\s+\\d{1,2}:\\d{1,2}:\\d{1,2}(\\.\\d+)?\\s+(\+|-)\\d{4}/A' |
HUNK | '/@@ -(\\d+)(,(\\d+))?\\s+\\+(\\d+)(,(\\d+))?\\s+@@($)/A' |
SPLIT | '/(\r\n)|(\r)|(\n)/' |
Members
protected
- $destinations — array
- $instance — array
- $patches — array
- $removals — array
- $sources — array
Methods
protected
- __construct() — Constructor
- applyHunk() — Apply the patch
- findHeader() — Find the diff header
- findHunk() — Find the next hunk of difference
- getDestination() — Get the lines of a destination file
- getSource() — Get the lines of a source file
- splitLines() — Separate CR or CRLF lines
public
- add() — Add a unified diff string to the patcher
- addFile() — Add a unified diff file to the patcher
- apply() — Apply the patches
- getInstance() — Method to get a patcher
- reset() — Reset the pacher