
View on github
Step1: package.json
"activationCommands": {
"atom-workspace": "Exec-in-cmd:start"
},
Step2: lib/exec.coffee
This file can get the filepath. and give these parameters to lib/open.exe
To be frank, this file is rewritten by other package "open_in_cmd"
//omit 略
exec "start #{dir_name}\\open.exe #{dir_path} #{basename} #{extname} #{dir_name}"
Step3: lib/open.exe made by C lang
//omit 略
int execAndGet(char* cmd, char* result){
// 略 omit
}
int clean(char *p){
*p='\0';
}
float exec(char str[]){
//omit 略
system(str);
//omit 略
}
int main(int argc, char *argv[]){
//strcmp is a function compare two strings. If they are same, return 0
//argv[1] return path (not including \)
//argv[2] return filename (not including extension)
//argv[3] return filename extension (including point)
//argv[4] return this open.c's path (not including \)
char str[1024]="",str2[1024]="";
int error=0,exit=0,packageFlag=0;
float compile_time=0.0,exec_time=0.0,total_time=0.0;
clock_t start_compile_time,end_compile_time;
sprintf(str,"cd \"%s\"",argv[1]);
if(strcmp(argv[3],".java")==0){
//omit 略
}else if(strcmp(argv[3],".c")==0 || strcmp(argv[3],".cpp")==0){
//omit 略
}else if(strcmp(argv[3],".py")==0){
sprintf(str,"%s & python \"%s%s\"",str,argv[2],argv[3]);
}else if(strcmp(argv[3],".go")==0){
sprintf(str,"%s & go run \"%s%s\"",str,argv[2],argv[3]);
}else if(strcmp(argv[3],".R")==0){
sprintf(str,"%s & chcp 65001 & cls & Rscript \"%s%s\"",str,argv[2],argv[3]);
}else if(strcmp(argv[3],".rb")==0){
sprintf(str,"%s & chcp 65001 & cls & ruby \"%s%s\"",str,argv[2],argv[3]);
}else if(strcmp(argv[3],".html")==0 || strcmp(argv[3],".htm")==0 || strcmp(argv[3],".pdf")==0 || strcmp(argv[3],".lnk")==0){
sprintf(str,"%s & start \"\" \"%s\\%s%s\"",str,argv[1],argv[2],argv[3]);
exit=1; //We don't need cmd window if we open the types of files
}else{
error=(argv[0]==0)? 2:1;
}
if(error==1){
printf("The filepath extension is not supported.\n");
}else if(error==2){
printf("You have not chosen a file.");
}else{
//omit 略
}
if(exit==0){
system("pause");
}
return 0;
}