pre
This commit is contained in:
@@ -528,3 +528,60 @@ func ZipOneFile(srcFile, dstZip string, pathFlag bool) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ZipDirectoryFile(srcDir, dstZip string, pathFlag bool) error {
|
||||
// Create a new zip file
|
||||
zipfileWriter, err := os.Create(dstZip)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer zipfileWriter.Close()
|
||||
|
||||
// Create a new zip archive
|
||||
zipWriter := zip.NewWriter(zipfileWriter)
|
||||
defer zipWriter.Close()
|
||||
|
||||
// Walk through the directory and add files to the zip archive
|
||||
err = filepath.Walk(srcDir, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Create a new file header for the current file
|
||||
header, err := zip.FileInfoHeader(info)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Set the name of the file within the zip archive
|
||||
header.Name = filepath.Join(filepath.Base(srcDir), path[len(srcDir):])
|
||||
|
||||
// If the current file is a directory, skip it
|
||||
if info.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Create a new file in the zip archive
|
||||
fileWriter, err := zipWriter.CreateHeader(header)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Open the current file
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
// Copy the contents of the current file to the zip archive
|
||||
_, err = io.Copy(fileWriter, file)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ func init() {
|
||||
Register("PUT", dbrest.XormCommonUri, dbrest.DatabaseUpdateData, updatePermission)
|
||||
Register("DELETE", dbrest.XormCommonUri, dbrest.DatabaseDeleteData, deletePermission)
|
||||
|
||||
Register("GET", dbrest.XormDatabaseUri, dbrest.TaskDatabaseGetData, midware.CheckPermission)
|
||||
Register("GET", dbrest.XormDatabaseUri, dbrest.TaskDatabaseGetData, selectPermission)
|
||||
Register("POST", dbrest.XormDatabaseUri, dbrest.TaskDatabaseInsertData, insertPermission)
|
||||
Register("PUT", dbrest.XormDatabaseUri, dbrest.TaskDatabaseUpdateData, updatePermission)
|
||||
Register("DELETE", dbrest.XormDatabaseUri, dbrest.TaskDatabaseDeleteData, deletePermission)
|
||||
|
||||
1
makefile
1
makefile
@@ -91,6 +91,7 @@ deb: $(BINNAME)
|
||||
cp -rf $(EmsFEDir)/* $(FrontBuildDir)/front >/dev/null
|
||||
chmod 755 $(BinDir)/*
|
||||
chmod 755 $(BuildDir)/omc/bin/*
|
||||
chmod 755 $(DebBuildDir)/DEBIAN/preinst
|
||||
chmod 755 $(DebBuildDir)/DEBIAN/postinst
|
||||
chmod 755 $(DebBuildDir)/DEBIAN/postrm
|
||||
cp -rf $(BuildDir)/omc/* $(DebBuildDir)/usr/local/omc/
|
||||
|
||||
Reference in New Issue
Block a user