@@ -3,6 +3,7 @@ package leetcode
33import (
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
189193func handleCodeGolang (question questionType , code codeSnippetsType ) {
@@ -209,11 +213,11 @@ func handleCodeGolang(question questionType, code codeSnippetsType) {
209213}
210214
211215func 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
215219func 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
219223func handleCodeSQL (question questionType , code codeSnippetsType ) {
0 commit comments