MCPcopy
hub / github.com/ChineseSubFinder/ChineseSubFinder / WriteFile

Function WriteFile

pkg/util.go:576–605  ·  view source on GitHub ↗

WriteFile 写文件

(desFileFPath string, bytes []byte)

Source from the content-addressed store, hash-verified

574
575// WriteFile 写文件
576func WriteFile(desFileFPath string, bytes []byte) error {
577 var err error
578 nowDesPath := desFileFPath
579 if filepath.IsAbs(nowDesPath) == false {
580 nowDesPath, err = filepath.Abs(nowDesPath)
581 if err != nil {
582 return err
583 }
584 }
585 // 创建对应的目录
586 nowDirPath := filepath.Dir(nowDesPath)
587 err = os.MkdirAll(nowDirPath, os.ModePerm)
588 if err != nil {
589 return err
590 }
591 file, err := os.Create(nowDesPath)
592 if err != nil {
593 return err
594 }
595 defer func() {
596 _ = file.Close()
597 }()
598
599 _, err = file.Write(bytes)
600 if err != nil {
601 return err
602 }
603
604 return nil
605}
606
607// GetNowTimeString 获取当前的时间,没有秒
608func GetNowTimeString() (string, int, int, int) {

Callers 7

SaveTranslatedMethod · 0.92
processOneFileFunction · 0.92
un7zOneFileFunction · 0.92
OrganizeDlSubFilesFunction · 0.92
DownloadFileAddMethod · 0.92
TaskQueueSaveMethod · 0.92

Calls 1

CloseMethod · 0.45

Tested by

no test coverage detected