static BOOL install_from_unix_file(const char *dir, const char *subdir, const char *file_name) { LPWSTR dos_file_name; char *file_path; int fd, len; BOOL ret; static WCHAR * (CDECL *wine_get_dos_file_name)(const char*); static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2','.','d','l','l',0}; len = strlen(dir); file_path = heap_alloc(len+strlen(subdir)+strlen(file_name)+3); if(!file_path) return FALSE; memcpy(file_path, dir, len); if(len && file_path[len-1] != '/' && file_path[len-1] != '\\') file_path[len++] = '/'; if(*subdir) { strcpy(file_path+len, subdir); len += strlen(subdir); file_path[len++] = '/'; } strcpy(file_path+len, file_name); fd = open(file_path, O_RDONLY); if(fd == -1) { TRACE("%s not found\n", debugstr_a(file_path)); heap_free(file_path); return FALSE; } close(fd); if(!wine_get_dos_file_name) wine_get_dos_file_name = (void*)GetProcAddress(GetModuleHandleW(kernel32W), "wine_get_dos_file_name"); if(wine_get_dos_file_name) { /* Wine UNIX mode */ dos_file_name = wine_get_dos_file_name(file_path); if(!dos_file_name) { ERR("Could not get dos file name of %s\n", debugstr_a(file_path)); heap_free(file_path); return FALSE; } } else { /* Windows mode */ UINT res; WARN("Could not get wine_get_dos_file_name function, calling install_cab directly.\n"); res = MultiByteToWideChar( CP_ACP, 0, file_path, -1, 0, 0); dos_file_name = heap_alloc (res*sizeof(WCHAR)); MultiByteToWideChar( CP_ACP, 0, file_path, -1, dos_file_name, res); } heap_free(file_path); ret = install_file(dos_file_name); heap_free(dos_file_name); return ret; }
static BOOL get_mono_path(LPWSTR path) { static const WCHAR subdir_mono[] = {'\\','m','o','n','o',0}; static const WCHAR sibling_mono[] = {'\\','.','.','\\','m','o','n','o',0}; WCHAR base_path[MAX_PATH]; const char *unix_data_dir; WCHAR *dos_data_dir; BOOL build_tree = FALSE; static WCHAR* (CDECL *wine_get_dos_file_name)(const char*); /* First try c:\windows\mono */ GetWindowsDirectoryW(base_path, MAX_PATH); strcatW(base_path, subdir_mono); if (get_mono_path_from_folder(base_path, path)) return TRUE; /* Next: /usr/share/wine/mono */ unix_data_dir = wine_get_data_dir(); if (!unix_data_dir) { unix_data_dir = wine_get_build_dir(); build_tree = TRUE; } if (unix_data_dir) { if (!wine_get_dos_file_name) wine_get_dos_file_name = (void*)GetProcAddress(GetModuleHandleA("kernel32"), "wine_get_dos_file_name"); if (wine_get_dos_file_name) { dos_data_dir = wine_get_dos_file_name(unix_data_dir); if (dos_data_dir) { strcpyW(base_path, dos_data_dir); strcatW(base_path, build_tree ? sibling_mono : subdir_mono); HeapFree(GetProcessHeap(), 0, dos_data_dir); if (get_mono_path_from_folder(base_path, path)) return TRUE; } } } /* Last: the registry */ return get_mono_path_from_registry(path); }
static BOOL install_from_unix_file(const char *file_name) { LPWSTR dos_file_name; int fd; BOOL ret; static WCHAR * (CDECL *wine_get_dos_file_name)(const char*); static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2','.','d','l','l',0}; fd = open(file_name, O_RDONLY); if(fd == -1) { TRACE("%s not found\n", debugstr_a(file_name)); return FALSE; } close(fd); if(!wine_get_dos_file_name) wine_get_dos_file_name = (void*)GetProcAddress(GetModuleHandleW(kernel32W), "wine_get_dos_file_name"); if(wine_get_dos_file_name) { /* Wine UNIX mode */ dos_file_name = wine_get_dos_file_name(file_name); if(!dos_file_name) { ERR("Could not get dos file name of %s\n", debugstr_a(file_name)); return FALSE; } } else { /* Windows mode */ UINT res; WARN("Could not get wine_get_dos_file_name function, calling install_cab directly.\n"); res = MultiByteToWideChar( CP_ACP, 0, file_name, -1, 0, 0); dos_file_name = heap_alloc (res*sizeof(WCHAR)); MultiByteToWideChar( CP_ACP, 0, file_name, -1, dos_file_name, res); } ret = install_file(dos_file_name); heap_free(dos_file_name); return ret; }
static BOOL install_from_unix_file(const char *file_name) { LPWSTR dos_file_name; int fd; BOOL ret; static WCHAR *(*wine_get_dos_file_name)(const char*); static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2','.','d','l','l',0}; fd = open(file_name, O_RDONLY); if(fd == -1) { TRACE("%s not found\n", debugstr_a(file_name)); return FALSE; } close(fd); if(!wine_get_dos_file_name) { wine_get_dos_file_name = (void*)GetProcAddress(GetModuleHandleW(kernel32W), "wine_get_dos_file_name"); if(!wine_get_dos_file_name) { ERR("Could not get wine_get_dos_file_name function.\n"); return FALSE; } } dos_file_name = wine_get_dos_file_name(file_name); if(!dos_file_name) { ERR("Could not get dos file name of %s\n", debugstr_a(file_name)); return FALSE; } ret = install_cab(dos_file_name); heap_free(dos_file_name); return ret; }
static HRESULT TRASH_GetDetails(const TRASH_BUCKET *bucket, LPCSTR filename, WIN32_FIND_DATAW *data) { LPSTR path = NULL; XDG_PARSED_FILE *parsed = NULL; char *original_file_name = NULL; char *deletion_date = NULL; int fd = -1; struct stat stats; HRESULT ret = S_FALSE; LPWSTR original_dos_name; int suffix_length = lstrlenA(trashinfo_suffix); int filename_length = lstrlenA(filename); int files_length = lstrlenA(bucket->files_dir); int path_length = max(lstrlenA(bucket->info_dir), files_length); path = SHAlloc(path_length + filename_length + 1); if (path == NULL) return E_OUTOFMEMORY; wsprintfA(path, "%s%s", bucket->files_dir, filename); path[path_length + filename_length - suffix_length] = 0; /* remove the '.trashinfo' */ if (lstat(path, &stats) == -1) { ERR("Error accessing data file for trashinfo %s (errno=%d)\n", filename, errno); goto failed; } wsprintfA(path, "%s%s", bucket->info_dir, filename); fd = open(path, O_RDONLY); if (fd == -1) { ERR("Couldn't open trashinfo file %s (errno=%d)\n", path, errno); goto failed; } parsed = XDG_ParseDesktopFile(fd); if (parsed == NULL) { ERR("Parse error in trashinfo file %s\n", path); goto failed; } original_file_name = XDG_GetStringValue(parsed, trashinfo_group, "Path", XDG_URLENCODE); if (original_file_name == NULL) { ERR("No 'Path' entry in trashinfo file\n"); goto failed; } ZeroMemory(data, sizeof(*data)); data->nFileSizeHigh = (DWORD)((LONGLONG)stats.st_size>>32); data->nFileSizeLow = stats.st_size & 0xffffffff; RtlSecondsSince1970ToTime(stats.st_mtime, (LARGE_INTEGER *)&data->ftLastWriteTime); original_dos_name = wine_get_dos_file_name(original_file_name); if (original_dos_name != NULL) { lstrcpynW(data->cFileName, original_dos_name, MAX_PATH); SHFree(original_dos_name); } else { /* show only the file name */ char *file = strrchr(original_file_name, '/'); if (file == NULL) file = original_file_name; MultiByteToWideChar(CP_UNIXCP, 0, file, -1, data->cFileName, MAX_PATH); } deletion_date = XDG_GetStringValue(parsed, trashinfo_group, "DeletionDate", 0); if (deletion_date) { struct tm del_time; time_t del_secs; sscanf(deletion_date, "%d-%d-%dT%d:%d:%d", &del_time.tm_year, &del_time.tm_mon, &del_time.tm_mday, &del_time.tm_hour, &del_time.tm_min, &del_time.tm_sec); del_time.tm_year -= 1900; del_time.tm_mon--; del_time.tm_isdst = -1; del_secs = mktime(&del_time); RtlSecondsSince1970ToTime(del_secs, (LARGE_INTEGER *)&data->ftLastAccessTime); } ret = S_OK; failed: SHFree(path); SHFree(original_file_name); SHFree(deletion_date); if (fd != -1) close(fd); XDG_FreeParsedFile(parsed); return ret; }