コード例 #1
0
// Renames table files.
func Rename(path string, oldName string, newName string) int {
	for _, ext := range constant.TableFiles() {
		err := os.Rename(path+oldName+ext, path+newName+ext)
		if err != nil {
			logg.Err("tablefilemanager", "Rename", err)
			return st.CannotRenameTableFile
		}
	}
	for _, dir := range constant.TableDirs() {
		err := os.Rename(path+oldName+dir, path+newName+dir)
		if err != nil {
			logg.Err("tablefilemanager", "Rename", err)
			return st.CannotRenameTableDir
		}
	}
	return st.OK
}
コード例 #2
0
// Deletes table files
func Delete(path string, name string) int {
	for _, ext := range constant.TableFiles() {
		err := os.Remove(path + name + ext)
		if err != nil {
			logg.Err("tablefilemanager", "Delete", err)
			return st.CannotRemoveTableFile
		}
	}
	for _, dir := range constant.TableDirs() {
		err := os.RemoveAll(path + name + dir)
		if err != nil {
			logg.Err("tablefilemanager", "Delete", err)
			return st.CannotRemoveTableDir
		}
	}
	return st.OK
}
コード例 #3
0
// Creates table files.
func Create(path string, name string) int {
	if len(name) > constant.MaxTableNameLength {
		return st.TableNameTooLong
	}
	// Create table files with extension names.
	for _, ext := range constant.TableFiles() {
		_, err := os.Create(path + name + ext)
		if err != nil {
			logg.Err("tablefilemanager", "Create", err)
			return st.CannotCreateTableFile
		}
	}
	// Create table directories with name suffixes.
	for _, dir := range constant.TableDirs() {
		err := os.Mkdir(path+name+dir, constant.TableDirPerm)
		if err != nil {
			logg.Err("tablefilemanager", "Create", err)
			return st.CannotCreateTableDir
		}
	}
	return st.OK
}