• R/O
  • SSH
  • HTTPS

exewrap: Commit


Commit MetaInfo

Revision34 (tree)
Time2017-02-01 21:50:59
Authorhirukawa_ryo

Log Message

* 1.1.5 出力ファイルパスのディレクトリーが存在しない場合は自動的に作成するようにしました。

Change Summary

Incremental Difference

--- exewrap/trunk/exewrap/src/exewrap.c (revision 33)
+++ exewrap/trunk/exewrap/src/exewrap.c (revision 34)
@@ -1,6 +1,8 @@
11 #define _CRT_SECURE_NO_WARNINGS
22
33 #include <windows.h>
4+#include <Shlwapi.h>
5+#include <Shlobj.h>
46 #include <stdio.h>
57 #include <string.h>
68 #include <stdlib.h>
@@ -31,9 +33,6 @@
3133 static char* set_version_info(const char* filename, const char* version_number, DWORD previous_revision, char* file_description, char* copyright, char* company_name, char* product_name, char* product_version, char* original_filename, char* jar_file);
3234
3335
34-void UsePack200(LPCTSTR exefile, LPCTSTR jarfile);
35-
36-
3736 int main(int argc, char* argv[])
3837 {
3938 char** opt = NULL;
@@ -533,110 +532,6 @@
533532 ExitProcess(0);
534533 }
535534
536-
537-void UsePack200(LPCTSTR exefile, LPCTSTR jarfile)
538-{
539- /*
540- DWORD size;
541- char* buf;
542- jclass optimizerClass;
543- jmethodID optimizerInit;
544- jobject optimizer;
545- jmethodID getRelativeClassPath;
546- jmethodID getClassesPackGz;
547- jmethodID getResourcesGz;
548- jmethodID getSplashPath;
549- jmethodID getSplashImage;
550- jbyteArray relativeClassPath;
551- jbyteArray classesPackGz;
552- jbyteArray resourcesGz;
553- jbyteArray splashPath;
554- jbyteArray splashImage;
555-
556- buf = GetResource("JAR_OPTIMIZER", RT_RCDATA, &size);
557-
558- optimizerClass = (*env)->DefineClass(env, "JarOptimizer", NULL, (jbyte*)buf, size);
559- if(optimizerClass == NULL)
560- {
561- return;
562- }
563- optimizerInit = (*env)->GetMethodID(env, optimizerClass, "<init>", "(Ljava/lang/String;)V");
564- if(optimizerInit == NULL)
565- {
566- return;
567- }
568-
569- optimizer = (*env)->NewObject(env, optimizerClass, optimizerInit, GetJString(env, jarfile));
570- if(optimizer == NULL)
571- {
572- (*env)->ExceptionDescribe(env);
573- (*env)->ExceptionClear(env);
574- return;
575- }
576- getRelativeClassPath = (*env)->GetMethodID(env, optimizerClass, "getRelativeClassPath", "()[B");
577- if(getRelativeClassPath == NULL)
578- {
579- return;
580- }
581- getClassesPackGz = (*env)->GetMethodID(env, optimizerClass, "getClassesPackGz", "()[B");
582- if(getClassesPackGz == NULL)
583- {
584- return;
585- }
586- getResourcesGz = (*env)->GetMethodID(env, optimizerClass, "getResourcesGz", "()[B");
587- if(getResourcesGz == NULL)
588- {
589- return;
590- }
591- getSplashPath = (*env)->GetMethodID(env, optimizerClass, "getSplashPath", "()[B");
592- if(getSplashPath == NULL)
593- {
594- return;
595- }
596- getSplashImage = (*env)->GetMethodID(env, optimizerClass, "getSplashImage", "()[B");
597- if(getSplashImage == NULL)
598- {
599- return;
600- }
601- relativeClassPath = (jbyteArray)((*env)->CallObjectMethod(env, optimizer, getRelativeClassPath));
602- if(relativeClassPath != NULL)
603- {
604- size = (*env)->GetArrayLength(env, relativeClassPath);
605- buf = (char*)((*env)->GetByteArrayElements(env, relativeClassPath, NULL));
606- SetResource(exefile, "RELATIVE_CLASSPATH", RT_RCDATA, buf, size);
607- }
608- classesPackGz = (jbyteArray)((*env)->CallObjectMethod(env, optimizer, getClassesPackGz));
609- if(classesPackGz != NULL)
610- {
611- size = (*env)->GetArrayLength(env, classesPackGz);
612- buf = (char*)((*env)->GetByteArrayElements(env, classesPackGz, NULL));
613- SetResource(exefile, "CLASSES_PACK_GZ", RT_RCDATA, buf, size);
614- }
615- resourcesGz = (jbyteArray)((*env)->CallObjectMethod(env, optimizer, getResourcesGz));
616- if(resourcesGz != NULL)
617- {
618- size = (*env)->GetArrayLength(env, resourcesGz);
619- buf = (char*)((*env)->GetByteArrayElements(env, resourcesGz, NULL));
620- SetResource(exefile, "RESOURCES_GZ", RT_RCDATA, buf, size);
621- }
622- splashPath = (jbyteArray)((*env)->CallObjectMethod(env, optimizer, getSplashPath));
623- if(splashPath != NULL)
624- {
625- size = (*env)->GetArrayLength(env, splashPath);
626- buf = (char*)((*env)->GetByteArrayElements(env, splashPath, NULL));
627- SetResource(exefile, "SPLASH_PATH", RT_RCDATA, buf, size);
628- }
629- splashImage = (jbyteArray)((*env)->CallObjectMethod(env, optimizer, getSplashImage));
630- if(splashImage != NULL)
631- {
632- size = (*env)->GetArrayLength(env, splashImage);
633- buf = (char*)((*env)->GetByteArrayElements(env, splashImage, NULL));
634- SetResource(exefile, "SPLASH_IMAGE", RT_RCDATA, buf, size);
635- }
636- */
637-}
638-
639-
640535 static char** parse_opt(int argc, char* argv[])
641536 {
642537 char** opt = (char**)HeapAlloc(GetProcessHeap(), 0, 256 * 8);
@@ -729,7 +624,20 @@
729624 HANDLE hFile;
730625 BYTE* buf = NULL;
731626 DWORD write_size;
732-
627+ char* dir;
628+ char* ptr;
629+
630+ dir = malloc(strlen(filename) + 1);
631+ strcpy(dir, filename);
632+ if((ptr = strrchr(dir, '\\')) != NULL)
633+ {
634+ *ptr = '\0';
635+ if(!PathIsDirectory(dir))
636+ {
637+ SHCreateDirectoryEx(NULL, dir, NULL);
638+ }
639+ }
640+
733641 hFile = CreateFile(filename, GENERIC_WRITE, 0, NULL, TRUNCATE_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
734642 if (hFile == INVALID_HANDLE_VALUE)
735643 {
--- exewrap/trunk/exewrap/src/Makefile (revision 33)
+++ exewrap/trunk/exewrap/src/Makefile (revision 34)
@@ -1,6 +1,6 @@
11
22 INC = /I ..\include /I ..\include\win32
3-LIBS = kernel32.lib user32.lib advapi32.lib shell32.lib
3+LIBS = kernel32.lib user32.lib advapi32.lib shell32.lib Shlwapi.lib
44
55 CC = cl.exe
66 LINK = link.exe
Show on old repository browser