@@ -840,3 +840,111 @@ func (s *Shell) DiagNet(format string) ([]byte, error) {
840
840
841
841
return result .Bytes (), nil
842
842
}
843
+
844
+ // "/files/cp?arg=<source>&arg=<dest>"
845
+ func (s * Shell ) FilesCp (source string , dest string , flush bool ) (error ) {
846
+ req := s .newRequest (context .Background (), "files/cp" , source , dest )
847
+ if flush {
848
+ req .Opts ["flush" ] = "true"
849
+ } else {
850
+ req .Opts ["flush" ] = "false"
851
+ }
852
+
853
+ resp , err := req .Send (s .httpcli )
854
+ if err != nil {
855
+ return err
856
+ }
857
+ defer resp .Close ()
858
+
859
+ if resp .Error != nil {
860
+ return resp .Error
861
+ }
862
+ return nil
863
+ }
864
+
865
+ // "/files/flush?arg=<path>"
866
+ func (s * Shell ) FilesFlush (path string ) (error ) {
867
+ resp , err := s .newRequest (context .Background (), "files/flush" , path ).Send (s .httpcli )
868
+ if err != nil {
869
+ return err
870
+ }
871
+ defer resp .Close ()
872
+
873
+ if resp .Error != nil {
874
+ return resp .Error
875
+ }
876
+ return nil
877
+ }
878
+
879
+ // "/files/mkdir?arg=<path>"
880
+ func (s * Shell ) FilesMkdir (path string , parents bool ) (error ) {
881
+ req := s .newRequest (context .Background (),"files/mkdir" , path )
882
+ if parents {
883
+ req .Opts ["parents" ] = "true"
884
+ }
885
+
886
+ resp , err := req .Send (s .httpcli )
887
+
888
+ if err != nil {
889
+ return err
890
+ }
891
+ defer resp .Close ()
892
+
893
+ if resp .Error != nil {
894
+ return resp .Error
895
+ }
896
+ return nil
897
+ }
898
+
899
+ type FilesStatEntry struct {
900
+ Hash string
901
+ Name string
902
+ Size uint64
903
+ CumulativeSize uint64
904
+ Type string
905
+ }
906
+
907
+ func (s * Shell ) FilesStat (path string ) (* FilesStatEntry , error ) {
908
+ resp , err := s .newRequest (context .Background (), "files/stat" , path ).Send (s .httpcli )
909
+ if err != nil {
910
+ return nil , err
911
+ }
912
+ defer resp .Close ()
913
+
914
+ if resp .Error != nil {
915
+ return nil , resp .Error
916
+ }
917
+
918
+ var obj FilesStatEntry
919
+ err = json .NewDecoder (resp .Output ).Decode (& obj )
920
+ if err != nil {
921
+ return nil , err
922
+ }
923
+
924
+ return & obj , nil
925
+ }
926
+
927
+ type NamePublishEntry struct {
928
+ Value string
929
+ Name string
930
+ }
931
+
932
+ func (s * Shell ) NamePublish (path string ) (* NamePublishEntry , error ) {
933
+ resp , err := s .newRequest (context .Background (), "name/publish" , path ).Send (s .httpcli )
934
+ if err != nil {
935
+ return nil , err
936
+ }
937
+ defer resp .Close ()
938
+
939
+ if resp .Error != nil {
940
+ return nil , resp .Error
941
+ }
942
+
943
+ var obj NamePublishEntry
944
+ err = json .NewDecoder (resp .Output ).Decode (& obj )
945
+ if err != nil {
946
+ return nil , err
947
+ }
948
+
949
+ return & obj , nil
950
+ }
0 commit comments