00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #define strict
00012
00013 #include <windows.h>
00014 #include <shlobj.h>
00015
00016 #include "utils.h"
00017
00018
00019
00020
00021
00022
00023
00024 int GetOpenFilename(TCHAR *MatchType, TCHAR *MatchFile, TCHAR* fileName)
00025 {
00026 OPENFILENAME fn;
00027 register int i;
00028 char Filter[128];
00029 TCHAR DefaultFile[512];
00030
00031
00032 lstrcpy(Filter, MatchType);
00033 i = lstrlen(Filter) + 1;
00034 lstrcpy(&Filter[i],MatchFile);
00035 i += lstrlen(&Filter[i]) + 1;
00036 Filter[i] = '\0';
00037
00038
00039 fn.lStructSize = sizeof(OPENFILENAME);
00040 fn.hwndOwner = GetActiveWindow();
00041 fn.lpstrFilter = Filter;
00042 fn.lpstrCustomFilter = NULL;
00043 fn.nFilterIndex = 0;
00044 fn.lpstrFile = NULL;
00045 fn.lpstrFile = DefaultFile;
00046 fn.nMaxFile = sizeof(DefaultFile);
00047 fn.lpstrFileTitle = NULL;
00048 fn.lpstrInitialDir = NULL;
00049 fn.lpstrTitle = NULL;
00050 fn.Flags = OFN_READONLY;
00051 fn.lpstrDefExt = &MatchFile[2];
00052 *DefaultFile = '\0';
00053
00054
00055 if (GetOpenFileName(&fn))
00056 {
00057 lstrcpy(fileName, DefaultFile);
00058 return TRUE;
00059 }
00060 else
00061 return FALSE;
00062 }
00063
00064
00065
00066
00067
00068 void GetFolderName(TCHAR* fileName)
00069 {
00070 TCHAR path[MAX_PATH];
00071 LPITEMIDLIST pidl;
00072
00073 BROWSEINFO bi = { 0 };
00074 bi.lpszTitle = "Select your Workspace";
00075 bi.pszDisplayName = path;
00076 bi.ulFlags = BIF_RETURNONLYFSDIRS;
00077
00078 pidl = SHBrowseForFolder ( &bi );
00079 if ( pidl != 0 )
00080 {
00081 TCHAR szDir[MAX_PATH];
00082 if( SHGetPathFromIDList( pidl, szDir ) )
00083 {
00084 strcpy(fileName, szDir);
00085 }
00086 }
00087 }
00088
00098 BOOL lockfileIsDeleteable(TCHAR* pathToWorkspace)
00099 {
00100 TCHAR path[MAX_PATH];
00101
00102 wsprintf(path, "%s\\.metadata\\.lock", pathToWorkspace);
00103 if(DeleteFile(path))
00104 {
00105 return FALSE;
00106 }
00107 else
00108 {
00109 return TRUE;
00110 }
00111 }
00112
00113
00114
00115
00116
00117
00118 TCHAR* LocString(int messageId, TCHAR* buffer)
00119 {
00120 LoadString(getApplicationInstance(), messageId, buffer, STRINGBUFFER_SIZE);
00121
00122 return(buffer);
00123 }
00124
00125
00126
00127
00128 HINSTANCE getApplicationInstance()
00129 {
00130 return GetModuleHandle(NULL);
00131 }