You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 10, 2020. It is now read-only.
Copy file name to clipboardExpand all lines: SPEC/FILES.md
+24-9Lines changed: 24 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -601,7 +601,7 @@ The Mutable File System (MFS) is a virtual file system on top of IPFS that expos
601
601
Where:
602
602
603
603
-`from` is the path(s) of the source to copy. It might be:
604
-
- An existing MFS path (e.g. `/my-dir/my-file.txt`)
604
+
- An existing MFS path to a file or a directory (e.g. `/my-dir/my-file.txt`)
605
605
- An IPFS path (e.g. `/ipfs/QmWGeRAEgtsHW3ec7U4qW2CyVy7eA2mFRVbk1nb24jFyks`)
606
606
-`to` is the path of the destination to copy to
607
607
-`options` is an optional Object that might contain the following keys:
@@ -611,7 +611,11 @@ Where:
611
611
-`flush` is a Boolean value to decide whether or not to immediately flush MFS changes to disk (default: true)
612
612
-`callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occured if the operation was not successful
613
613
614
-
If there are multiple sources, `to` will be treated as a directory, otherwise it will be treated as the same type as `from`.
614
+
If `from` has multiple values then `to` must be a directory.
615
+
616
+
If `from` has a single value and `to` exists and is a directory, `from` will be copied into `to`.
617
+
618
+
If `from` has a single value and `to` exists and is a file, `from` must be a file and the contents of `to` will be replaced with the contents of `from` otherwise an error will be returned.
615
619
616
620
If `from` is an IPFS path, and an MFS path exists with the same name, the IPFS path will be chosen.
617
621
@@ -620,18 +624,21 @@ If no `callback` is passed, a promise is returned.
-`hash` is a Boolean value to return only the hash (default: false)
685
692
-`size` is a Boolean value to return only the size (default: false)
686
693
-`withLocal` is a Boolean value to compute the amount of the dag that is local, and if possible the total size (default: false)
687
-
-`callback` is an optional function with the signature `function (error, stats) {}`, where `error` may be an Error that occured if the operation was not successful and `stat` is an Object with the following keys:
694
+
-`callback` is an optional function with the signature `function (error, stats) {}`, where `error` may be an Error that occured if the operation was not successful and `stats` is an Object with the following keys:
-`path` is the path of the file to read and must point to a file
831
+
-`path` is the path of the file to read and must point to a file (and not a directory)
825
832
-`options` is an optional Object that might contain the following keys:
826
833
-`offset` is an Integer with the byte offset to begin reading from (default: 0)
827
834
-`length` is an Integer with the maximum number of bytes to read (default: Read to end of stream)
@@ -893,7 +900,15 @@ Where:
893
900
-`flush` is a Boolean value to decide whether or not to immediately flush MFS changes to disk (default: true)
894
901
-`callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occured if the operation was not successful
895
902
896
-
If there are multiple sources, `to` will be treated as a directory, otherwise it will be treated as the same type as `from`.
903
+
If `from` has multiple values then `to` must be a directory.
904
+
905
+
If `from` has a single value and `to` exists and is a directory, `from` will be moved into `to`.
906
+
907
+
If `from` has a single value and `to` exists and is a file, `from` must be a file and the contents of `to` will be replaced with the contents of `from` otherwise an error will be returned.
908
+
909
+
If `from` is an IPFS path, and an MFS path exists with the same name, the IPFS path will be chosen.
910
+
911
+
All values of `from` will be removed after the operation is complete, unless they are an IPFS path.
897
912
898
913
If no `callback` is passed, a promise is returned.
0 commit comments