-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add file permissions constants - Add function to handle filenames - Add function to handle writing files - Files shouldn't be executable - Files shouldn't use spaces in file names for multi-OS support
- Loading branch information
1 parent
60895be
commit 5aa7472
Showing
8 changed files
with
70 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
Copyright (C) 2018 OpenControl Contributors. See LICENSE.md for license. | ||
*/ | ||
|
||
package constants | ||
|
||
const ( | ||
// FileReadWrite handle Read/Write File Permissions | ||
FileReadWrite = 0600 | ||
|
||
// FileReadWriteExec handle Read/Write/Write Execute Permissions | ||
FileReadWriteExec = 0700 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
Copyright (C) 2018 OpenControl Contributors. See LICENSE.md for license. | ||
*/ | ||
|
||
package masonryutil | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"strings" | ||
) | ||
|
||
// replaceParentheses removes parenthesis in strings | ||
func replaceParentheses(text string) string { | ||
return strings.Replace(strings.Replace(text, "(", "", -1), ")", "", -1) | ||
} | ||
|
||
// replaceSpace changes whitepspace to underscore in strings | ||
func replaceSpaceUnderscore(text string) string { | ||
return strings.Replace(text, " ", "_", -1) | ||
} | ||
|
||
// FileNameHandler creates a standardized filename | ||
func FileNameHandler(fileName string) string { | ||
normalizedFileName := replaceParentheses(fileName) | ||
normalizedFileName = replaceSpaceUnderscore(normalizedFileName) | ||
|
||
return normalizedFileName | ||
} | ||
|
||
// FileWriter handles all file writing for Compliance Masonry | ||
func FileWriter(filePath string, fileText []byte, filePerms os.FileMode) { | ||
err := ioutil.WriteFile(filePath, fileText, filePerms) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters