package file

import (
	"os"
	"path/filepath"
)

func FileRename(userName, filePath, newFilePath string) error {

	// 获取main.go所在的目录
	currentDir, err := os.Getwd()
	if err != nil {
		return err
	}

	baseDir := filepath.Join(currentDir, "file_library")

	oldfullFilePath := filepath.Join(baseDir, userName, filePath)

	newfullFilePath := filepath.Join(baseDir, userName, newFilePath)

	err = os.Rename(oldfullFilePath, newfullFilePath)
	if err != nil {
		return err
	}

	return nil
}
