示例#1
0
文件: ccpp.go 项目: kien8995/judger
// 创建编译环境的目录结构
func (this *Compile) createDirs(id int, sid string) error {
	var err error
	err = nil
	this.userBuildPath = filepath.Join(this.buildPath, sid)
	if !com.PathExist(this.userBuildPath) {
		err = com.Mkdir(this.userBuildPath)
	}
	this.itemBuildPath = filepath.Join(this.userBuildPath, fmt.Sprintf("%d", id))
	if !com.PathExist(this.itemBuildPath) {
		err = com.Mkdir(this.itemBuildPath)
	}
	return err
}
示例#2
0
文件: fis.go 项目: dw250100785/blog-1
func createDirs(path string) {
	createPath := ""
	pathArr := strings.Split(path, "/")
	for i := 0; i < len(pathArr); i++ {
		createPath = createPath + pathArr[i] + "/"
		if !com.FileExist(createPath) {
			com.Mkdir(createPath)
		}
	}
}
示例#3
0
文件: init.go 项目: kien8995/judger
func createBuildDir() error {
	var err error
	err = nil

	buildPath := filepath.Join(C.Get(runtime.GOOS, "buildpath"))
	if !com.PathExist(buildPath) {
		err = com.Mkdir(buildPath)
	}

	return err
}
示例#4
0
文件: init.go 项目: kien8995/judger
func Judger() {
	parseArg()

	dataPath := "data.db"

	if Mode == "docker" {
		log.Blueln("[mode]", "docker")

		if !com.FileExist("/data") {
			if err := com.Mkdir("/data"); err != nil {
				log.Warnln("[Warn]", "create dir /data failed")
			} else {
				log.Blueln("[info]", "create dir /data")
			}
		}

		if !com.FileExist("/data/config_docker.ini") {
			com.CopyFile("/data/config_docker.ini", "conf/config_docker.ini")
		}

		if !com.FileExist("/data/executer.json") {
			com.CopyFile("/data/executer.json", "sandbox/c/build/executer.json")
		}

		dataPath = "/data/data.db"
	}

	if configFile == "" {
		configFile = "conf/config.ini"
	}

	if !com.FileExist(configFile) {
		log.Dangerln("[Error]", configFile, "does not exist!")
		os.Exit(-1)
	}

	log.Blueln("[config]")
	log.Blueln(configFile)

	C = &Config{}
	C.NewConfig(configFile)

	GenScript()

	log.Blueln("[data]")
	log.Blueln(dataPath)
	DB = &Sqlite{}
	DB.NewSqlite(dataPath)

	createBuildDir()

	go TcpStart()
	HttpStart()
}
示例#5
0
func githubStat() error {
	if !com.FileExist("static") {
		com.Mkdir("static")
	} else {
		if com.FileExist("static/upload") {
			com.Mkdir("static/upload")
		}
	}

	token := beego.AppConfig.String("github_token")
	user := beego.AppConfig.String("github_user")

	json, err := statistics.GetRepos(user, token)

	if err != nil {
		return err
	}

	stat := beego.AppConfig.String("github_statistics")

	err = com.WriteFile(stat, json)

	return err
}
示例#6
0
文件: session_test.go 项目: elago/ela
func TestSession(t *testing.T) {

	Convey("Test Session sections", t, func() {
		com.Mkdir("tmp")
		sess := NewSession("tmp")
		path := sess.getPath("ABCDEFGHIJKLMNOPQRST")

		So(path, ShouldEqual, filepath.Join("tmp", "A", "BC", "DEFGHIJKLMNOPQRST"))

		sess.Set("ABCDEFGHIJKLMNOPQRST", "key", "ABCDEFGHIJKLMNOPQRST")
		sess.Set("ABCDEFGHIJKLMNOPQRST", "number", 123456)
		obj, _ := sess.Get("ABCDEFGHIJKLMNOPQRST", "key")
		number, _ := sess.Get("ABCDEFGHIJKLMNOPQRST", "number")

		So(obj.(string), ShouldEqual, "ABCDEFGHIJKLMNOPQRST")
		So(number.(int), ShouldEqual, 123456)

	})

}
示例#7
0
func GenScript() {
	currentPath, _ := os.Getwd()

	gccWin := `"%s\bin\%s.exe" %%1 -g3 -I"%s\include" -L"%s\lib" -g3 1> BUILD.LOG 2>&1
echo %%ERRORLEVEL%% > BUILDRESULT`

	gccNix := `%s $1 1> BUILD.LOG 2>&1
echo $? > BUILDRESULT`

	var gccScript string
	var gppScript string

	if !com.FileExist("script") {
		com.Mkdir("script")
	}

	if runtime.GOOS == "windows" {
		gccWinPath := C.Get(runtime.GOOS, "gcc_path")
		gccScript = fmt.Sprintf(gccWin, gccWinPath, "gcc", gccWinPath, gccWinPath)
		gppScript = fmt.Sprintf(gccWin, gccWinPath, "g++", gccWinPath, gccWinPath)

		runWin := `"` + filepath.Join(currentPath, C.Get(runtime.GOOS, "executer_path")) + `" -t=%1 -m=%2 %3`

		com.WriteFile(C.Get(runtime.GOOS, "compiler_c"), gccScript)
		com.WriteFile(C.Get(runtime.GOOS, "compiler_cpp"), gppScript)
		com.WriteFile(C.Get(runtime.GOOS, "run_script"), runWin)
	} else {
		gccScript = fmt.Sprintf(gccNix, "gcc")
		gppScript = fmt.Sprintf(gccNix, "g++")
		runNix := filepath.Join(currentPath, C.Get(runtime.GOOS, "executer_path")) + ` -t=$1 -m=$2 $3 -c=` + C.Get(runtime.GOOS, "executer_config")

		com.WriteFile(C.Get(runtime.GOOS, "compiler_c"), gccScript)
		com.WriteFile(C.Get(runtime.GOOS, "compiler_cpp"), gppScript)
		com.WriteFile(C.Get(runtime.GOOS, "run_script"), runNix)

		os.Chmod(C.Get(runtime.GOOS, "compiler_c"), 0755)
		os.Chmod(C.Get(runtime.GOOS, "compiler_cpp"), 0755)
		os.Chmod(C.Get(runtime.GOOS, "run_script"), 0755)
	}

}