1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Mupen64plus-ui-console - osal_files_win32.c *
3 * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
4 * Copyright (C) 2009 Richard Goedeken *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
22 /* This implements all kinds of system-dependent file handling
32 #include "m64p_types.h"
33 #include "osal_preproc.h"
34 #include "osal_files.h"
36 /* definitions for system directories to search when looking for mupen64plus plugins */
37 const int osal_libsearchdirs = 1;
38 const char *osal_libsearchpath[1] = { ".\\" };
40 osal_lib_search *osal_library_search(const char *searchpath)
42 osal_lib_search *head = NULL, *curr = NULL;
43 WIN32_FIND_DATA entry;
46 char *pchSearchPath = (char *) malloc(strlen(searchpath) + 16);
47 if (pchSearchPath == NULL)
49 DebugMessage(M64MSG_ERROR, "Couldn't allocate memory for file search path in osal_library_search()!");
52 sprintf(pchSearchPath, "%s\\*.dll", searchpath);
53 hDir = FindFirstFile(pchSearchPath, &entry);
55 if (hDir == INVALID_HANDLE_VALUE)
58 /* look for any shared libraries in this folder */
61 osal_lib_search *newlib = NULL;
62 /* this is a .dll file, so add it to the list */
63 newlib = (osal_lib_search *) malloc(sizeof(osal_lib_search));
66 DebugMessage(M64MSG_ERROR, "Memory allocation error in osal_library_search()!");
67 osal_free_lib_list(head);
80 /* set up the filepath and filename members */
81 strncpy(curr->filepath, searchpath, PATH_MAX-2);
82 curr->filepath[PATH_MAX-2] = 0;
83 if (curr->filepath[strlen(curr->filepath)-1] != '\\')
84 strcat(curr->filepath, "\\");
85 int pathlen = (int) strlen(curr->filepath);
86 curr->filename = curr->filepath + pathlen;
87 strncat(curr->filepath, entry.cFileName, PATH_MAX - pathlen - 1);
88 curr->filepath[PATH_MAX-1] = 0;
89 /* set plugin_type and next pointer */
90 curr->plugin_type = (m64p_plugin_type) 0;
92 } while (FindNextFile(hDir, &entry));
98 void osal_free_lib_list(osal_lib_search *head)
102 osal_lib_search *next = head->next;