File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,6 +126,24 @@ namespace vfs {
126126 return this . _shadowRoot ;
127127 }
128128
129+ /**
130+ * Snapshots the current file system, effectively shadowing itself. This is useful for
131+ * generating file system patches using `.diff()` from one snapshot to the next. Performs
132+ * no action if this file system is read-only.
133+ */
134+ public snapshot ( ) {
135+ if ( this . isReadonly ) return ;
136+ const fs = new FileSystem ( this . ignoreCase , { time : this . _time } ) ;
137+ fs . _lazy = this . _lazy ;
138+ fs . _cwd = this . _cwd ;
139+ fs . _time = this . _time ;
140+ fs . _shadowRoot = this . _shadowRoot ;
141+ fs . _dirStack = this . _dirStack ;
142+ fs . makeReadonly ( ) ;
143+ this . _lazy = { } ;
144+ this . _shadowRoot = fs ;
145+ }
146+
129147 /**
130148 * Gets a shadow copy of this file system. Changes to the shadow copy do not affect the
131149 * original, allowing multiple copies of the same core file system without multiple copies
You can’t perform that action at this time.
0 commit comments