@@ -3,6 +3,7 @@ package leetcode
3
3
import (
4
4
"bytes"
5
5
"fmt"
6
+ "os"
6
7
"path"
7
8
"regexp"
8
9
"strings"
@@ -181,9 +182,12 @@ func (question questionType) SaveCodeSnippet() {
181
182
}
182
183
}
183
184
184
- func (question questionType ) saveCodeContent (content , ext string ) {
185
+ func (question questionType ) saveCodeContent (content , ext string , permX ... bool ) {
185
186
filePath := question .getFilePath (question .TitleSnake () + ext )
186
187
filePutContents (filePath , []byte (content ))
188
+ if len (permX ) > 0 && permX [0 ] == true {
189
+ os .Chmod (filePath , 0755 )
190
+ }
187
191
}
188
192
189
193
func handleCodeGolang (question questionType , code codeSnippetsType ) {
@@ -209,11 +213,11 @@ func handleCodeGolang(question questionType, code codeSnippetsType) {
209
213
}
210
214
211
215
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 )
213
217
}
214
218
215
219
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 )
217
221
}
218
222
219
223
func handleCodeSQL (question questionType , code codeSnippetsType ) {
0 commit comments