Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 27650ac

Browse files
author
Sandy
authored
Merge pull request #229 from openset/develop
Add: permission x
2 parents 1185049 + 4c20ebf commit 27650ac

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

‎internal/leetcode/question_data.go‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package leetcode
33
import (
44
"bytes"
55
"fmt"
6+
"os"
67
"path"
78
"regexp"
89
"strings"
@@ -181,9 +182,12 @@ func (question questionType) SaveCodeSnippet() {
181182
}
182183
}
183184

184-
func (question questionType) saveCodeContent(content, ext string) {
185+
func (question questionType) saveCodeContent(content, ext string, permX...bool) {
185186
filePath := question.getFilePath(question.TitleSnake() + ext)
186187
filePutContents(filePath, []byte(content))
188+
if len(permX) > 0 && permX[0] == true {
189+
os.Chmod(filePath, 0755)
190+
}
187191
}
188192

189193
func handleCodeGolang(question questionType, code codeSnippetsType) {
@@ -209,11 +213,11 @@ func handleCodeGolang(question questionType, code codeSnippetsType) {
209213
}
210214

211215
func handleCodeBash(question questionType, code codeSnippetsType) {
212-
question.saveCodeContent("#!/usr/bin/env bash\n\n"+code.Code, ".bash")
216+
question.saveCodeContent("#!/usr/bin/env bash\n\n"+code.Code, ".bash", true)
213217
}
214218

215219
func handleCodePython(question questionType, code codeSnippetsType) {
216-
question.saveCodeContent("#!/usr/bin/env python\n\n"+code.Code, ".py")
220+
question.saveCodeContent("#!/usr/bin/env python\n\n"+code.Code, ".py", true)
217221
}
218222

219223
func handleCodeSQL(question questionType, code codeSnippetsType) {

‎problems/tenth-line/tenth_line.bash‎

100644100755
File mode changed.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /