Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
b926341d80
@ -22,6 +22,8 @@
|
||||
|
||||
#define LOCAL_LUA_DIR "Lua"
|
||||
|
||||
#define APPDATA_SUBDIR "\\HardWIRED"
|
||||
|
||||
#define THUMB_CACHE_SIZE 256
|
||||
|
||||
#ifndef M_PI
|
||||
|
14
src/main.c
14
src/main.c
@ -1716,6 +1716,20 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
i++;
|
||||
}
|
||||
else if (!strncmp(argv[i], "ddir", 4) && i+1<argc)
|
||||
{
|
||||
/*char * temppath;
|
||||
FILE *f;
|
||||
temppath = malloc(strlen(argv[i+1])+19);
|
||||
sprintf(temppath, "%s%s%s", argv[i+1], PATH_SEP, "powdertoydir.test")
|
||||
f = fopen(temppath, "wb");
|
||||
if(f){*/
|
||||
chdir(argv[i+1]);
|
||||
/* fclose(f);
|
||||
remove(temppath);
|
||||
}
|
||||
free(temppath);*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
80
src/misc.c
80
src/misc.c
@ -12,6 +12,8 @@
|
||||
#include <icondoc.h>
|
||||
#include <update.h>
|
||||
#if defined WIN32
|
||||
#include <Shlobj.h>
|
||||
#include <Shlwapi.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
@ -467,80 +469,132 @@ char * clipboard_pull_text()
|
||||
int register_extension()
|
||||
{
|
||||
#if defined WIN32
|
||||
int returnval;
|
||||
LONG rresult;
|
||||
HKEY newkey;
|
||||
char *currentfilename = exe_name();
|
||||
char *iconname = NULL;
|
||||
char *opencommand = NULL;
|
||||
char AppDataPath[MAX_PATH];
|
||||
iconname = malloc(strlen(currentfilename)+6);
|
||||
opencommand = malloc(strlen(currentfilename)+13);
|
||||
sprintf(iconname, "%s,-102", currentfilename);
|
||||
sprintf(opencommand, "\"%s\" open \"%%1\"", currentfilename);
|
||||
|
||||
//Create Roaming application data folder
|
||||
if(!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0, AppDataPath)))
|
||||
{
|
||||
returnval = 0;
|
||||
goto finalise;
|
||||
}
|
||||
|
||||
//Move Game executable into application data folder
|
||||
//TODO: Implement
|
||||
|
||||
opencommand = malloc(strlen(currentfilename)+53+strlen(AppDataPath));
|
||||
if((strlen(AppDataPath)+strlen(APPDATA_SUBDIR "\\Powder Toy"))<MAX_PATH)
|
||||
{
|
||||
strappend(AppDataPath, APPDATA_SUBDIR);
|
||||
#ifdef WIN32
|
||||
if(_mkdir(AppDataPath))
|
||||
#else
|
||||
if(mkdir(AppDataPath, 0755))
|
||||
#endif
|
||||
{
|
||||
returnval = 0;
|
||||
goto finalise;
|
||||
}
|
||||
strappend(AppDataPath, "\\Powder Toy");
|
||||
#ifdef WIN32
|
||||
if(_mkdir(AppDataPath))
|
||||
#else
|
||||
if(mkdir(AppDataPath, 0755))
|
||||
#endif
|
||||
{
|
||||
returnval = 0;
|
||||
goto finalise;
|
||||
}
|
||||
} else {
|
||||
returnval = 0;
|
||||
goto finalise;
|
||||
}
|
||||
sprintf(opencommand, "\"%s\" open \"%%1\" ddir \"%s\"", currentfilename, AppDataPath);
|
||||
|
||||
//Create extension entry
|
||||
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\.cps", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
|
||||
if (rresult != ERROR_SUCCESS) {
|
||||
return 0;
|
||||
returnval = 0;
|
||||
goto finalise;
|
||||
}
|
||||
rresult = RegSetValueEx(newkey, 0, 0, REG_SZ, (LPBYTE)"PowderToySave", strlen("PowderToySave")+1);
|
||||
if (rresult != ERROR_SUCCESS) {
|
||||
RegCloseKey(newkey);
|
||||
return 0;
|
||||
returnval = 0;
|
||||
goto finalise;
|
||||
}
|
||||
RegCloseKey(newkey);
|
||||
|
||||
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\.stm", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
|
||||
if (rresult != ERROR_SUCCESS) {
|
||||
return 0;
|
||||
returnval = 0;
|
||||
goto finalise;
|
||||
}
|
||||
rresult = RegSetValueEx(newkey, 0, 0, REG_SZ, (LPBYTE)"PowderToySave", strlen("PowderToySave")+1);
|
||||
if (rresult != ERROR_SUCCESS) {
|
||||
RegCloseKey(newkey);
|
||||
return 0;
|
||||
returnval = 0;
|
||||
goto finalise;
|
||||
}
|
||||
RegCloseKey(newkey);
|
||||
|
||||
//Create program entry
|
||||
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\PowderToySave", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
|
||||
if (rresult != ERROR_SUCCESS) {
|
||||
return 0;
|
||||
returnval = 0;
|
||||
goto finalise;
|
||||
}
|
||||
rresult = RegSetValueEx(newkey, 0, 0, REG_SZ, (LPBYTE)"Powder Toy Save", strlen("Powder Toy Save")+1);
|
||||
if (rresult != ERROR_SUCCESS) {
|
||||
RegCloseKey(newkey);
|
||||
return 0;
|
||||
returnval = 0;
|
||||
goto finalise;
|
||||
}
|
||||
RegCloseKey(newkey);
|
||||
|
||||
//Set DefaultIcon
|
||||
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\PowderToySave\\DefaultIcon", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
|
||||
if (rresult != ERROR_SUCCESS) {
|
||||
return 0;
|
||||
returnval = 0;
|
||||
goto finalise;
|
||||
}
|
||||
rresult = RegSetValueEx(newkey, 0, 0, REG_SZ, (LPBYTE)iconname, strlen(iconname)+1);
|
||||
if (rresult != ERROR_SUCCESS) {
|
||||
RegCloseKey(newkey);
|
||||
return 0;
|
||||
returnval = 0;
|
||||
goto finalise;
|
||||
}
|
||||
RegCloseKey(newkey);
|
||||
|
||||
//Set Launch command
|
||||
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\PowderToySave\\shell\\open\\command", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
|
||||
if (rresult != ERROR_SUCCESS) {
|
||||
return 0;
|
||||
returnval = 0;
|
||||
goto finalise;
|
||||
}
|
||||
rresult = RegSetValueEx(newkey, 0, 0, REG_SZ, (LPBYTE)opencommand, strlen(opencommand)+1);
|
||||
if (rresult != ERROR_SUCCESS) {
|
||||
RegCloseKey(newkey);
|
||||
return 0;
|
||||
returnval = 0;
|
||||
goto finalise;
|
||||
}
|
||||
RegCloseKey(newkey);
|
||||
|
||||
returnval = 1;
|
||||
finalise:
|
||||
|
||||
if(iconname) free(iconname);
|
||||
if(opencommand) free(opencommand);
|
||||
if(currentfilename) free(currentfilename);
|
||||
|
||||
return 1;
|
||||
return returnval;
|
||||
#elif defined(LIN32) || defined(LIN64)
|
||||
char *currentfilename = exe_name();
|
||||
FILE *f;
|
||||
|
Loading…
Reference in New Issue
Block a user