summaryrefslogtreecommitdiff
path: root/ldmicro/lib/freezeLD
diff options
context:
space:
mode:
authorRr422018-06-19 10:50:34 +0530
committerRr422018-06-19 10:50:34 +0530
commite0dee2ff8d0a6d74f6a07ff73d739d3ac6fd6b22 (patch)
tree3d26ab5388f73997306e362fb9b36ac7dbb43c52 /ldmicro/lib/freezeLD
parent3b50889ec56fedae54d7e9173006f6332a77fb02 (diff)
downloadLDMicroGtk-e0dee2ff8d0a6d74f6a07ff73d739d3ac6fd6b22.tar.gz
LDMicroGtk-e0dee2ff8d0a6d74f6a07ff73d739d3ac6fd6b22.tar.bz2
LDMicroGtk-e0dee2ff8d0a6d74f6a07ff73d739d3ac6fd6b22.zip
Updated freeze library to use home directory
Diffstat (limited to 'ldmicro/lib/freezeLD')
-rw-r--r--ldmicro/lib/freezeLD/freezeLD.cpp42
-rw-r--r--ldmicro/lib/freezeLD/freezeLD.h2
2 files changed, 25 insertions, 19 deletions
diff --git a/ldmicro/lib/freezeLD/freezeLD.cpp b/ldmicro/lib/freezeLD/freezeLD.cpp
index ea3fae2..880dfab 100644
--- a/ldmicro/lib/freezeLD/freezeLD.cpp
+++ b/ldmicro/lib/freezeLD/freezeLD.cpp
@@ -24,15 +24,16 @@ void FreezeWindowPosF(HWID hwid, char *subKey, char *name)
if (!Ld_CWD)
return;
- char* moveToKeyLocatin = (char *)malloc(strlen(name) + 30);
+ char* moveToKeyLocatin = (char *)malloc(strlen(name) + MAX_PATH);
if(!moveToKeyLocatin)
{
free(Ld_CWD);
return;
}
- sprintf(moveToKeyLocatin, "mkdir -p %s/%s", FREEZE_REGISTER, subKey);
+
+ sprintf(moveToKeyLocatin, "mkdir -p %s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
system(moveToKeyLocatin);
- sprintf(moveToKeyLocatin, "%s/%s", FREEZE_REGISTER, subKey);
+ sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
if (-1 == chdir(moveToKeyLocatin))
{
free(Ld_CWD);
@@ -148,13 +149,14 @@ void ThawWindowPosF(HWID hwid, char *subKey, char *name)
if (!Ld_CWD)
return;
- char* moveToKeyLocatin = (char *)malloc(strlen(name) + 30);
+ char* moveToKeyLocatin = (char *)malloc(strlen(name) + MAX_PATH);
if(!moveToKeyLocatin)
{
free(Ld_CWD);
return;
}
- sprintf(moveToKeyLocatin, "%s/%s", FREEZE_REGISTER, subKey);
+
+ sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
if (-1 == chdir(moveToKeyLocatin))
{
free(Ld_CWD);
@@ -162,8 +164,8 @@ void ThawWindowPosF(HWID hwid, char *subKey, char *name)
return;
}
free(moveToKeyLocatin);
-
- char *keyName = (char *)malloc(strlen(name) + 30);
+
+ char *keyName = (char *)malloc(strlen(name) + MAX_PATH);
if(!keyName)
{
free(Ld_CWD);
@@ -257,15 +259,16 @@ void FreezeDWORDF(DWORD val, char *subKey, char *name)
if (!Ld_CWD)
return;
- char* moveToKeyLocatin = (char *)malloc(strlen(name) + 30);
+ char* moveToKeyLocatin = (char *)malloc(strlen(name) + MAX_PATH);
if(!moveToKeyLocatin)
{
free(Ld_CWD);
return;
}
- sprintf(moveToKeyLocatin, "mkdir -p %s/%s", FREEZE_REGISTER, subKey);
+
+ sprintf(moveToKeyLocatin, "mkdir -p %s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
system(moveToKeyLocatin);
- sprintf(moveToKeyLocatin, "%s/%s", FREEZE_REGISTER, subKey);
+ sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
if (-1 == chdir(moveToKeyLocatin))
{
free(Ld_CWD);
@@ -296,13 +299,14 @@ DWORD ThawDWORDF(DWORD val, char *subKey, char *name)
if (!Ld_CWD)
return val;
- char* moveToKeyLocatin = (char *)malloc(strlen(name) + 30);
+ char* moveToKeyLocatin = (char *)malloc(strlen(name) + MAX_PATH);
if(!moveToKeyLocatin)
{
free(Ld_CWD);
return val;
}
- sprintf(moveToKeyLocatin, "%s/%s", FREEZE_REGISTER, subKey);
+
+ sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
if (-1 == chdir(moveToKeyLocatin))
{
free(Ld_CWD);
@@ -340,15 +344,16 @@ void FreezeStringF(char *val, char *subKey, char *name)
if (!Ld_CWD)
return;
- char* moveToKeyLocatin = (char *)malloc(strlen(name) + 30);
+ char* moveToKeyLocatin = (char *)malloc(strlen(name) + MAX_PATH);
if(!moveToKeyLocatin)
{
free(Ld_CWD);
return;
}
- sprintf(moveToKeyLocatin, "mkdir -p %s/%s", FREEZE_REGISTER, subKey);
+
+ sprintf(moveToKeyLocatin, "mkdir -p %s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
system(moveToKeyLocatin);
- sprintf(moveToKeyLocatin, "%s/%s", FREEZE_REGISTER, subKey);
+ sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
if (-1 == chdir(moveToKeyLocatin))
{
free(Ld_CWD);
@@ -356,7 +361,7 @@ void FreezeStringF(char *val, char *subKey, char *name)
return;
}
free(moveToKeyLocatin);
-
+
std::ofstream Register(name, std::ios::trunc);
Register << strlen(val)+1 << "\n";
Register << val;
@@ -377,13 +382,14 @@ void ThawStringF(char *val, int max, char *subKey, char *name)
if (!Ld_CWD)
return;
- char* moveToKeyLocatin = (char *)malloc(strlen(name) + 30);
+ char* moveToKeyLocatin = (char *)malloc(strlen(name) + MAX_PATH);
if(!moveToKeyLocatin)
{
free(Ld_CWD);
return;
}
- sprintf(moveToKeyLocatin, "%s/%s", FREEZE_REGISTER, subKey);
+
+ sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
if (-1 == chdir(moveToKeyLocatin))
{
free(Ld_CWD);
diff --git a/ldmicro/lib/freezeLD/freezeLD.h b/ldmicro/lib/freezeLD/freezeLD.h
index 5c00504..581466d 100644
--- a/ldmicro/lib/freezeLD/freezeLD.h
+++ b/ldmicro/lib/freezeLD/freezeLD.h
@@ -10,7 +10,7 @@
#ifndef __FREEZE_H
#define __FREEZE_H
-#define FREEZE_REGISTER "/usr/share/ldmicro"
+#define FREEZE_REGISTER ".ldmicro"
#define FREEZE_SUBKEY "LDMicro"