Started implementing support for the SubSystemTib field in the TEB of
[wine] / dlls / dbghelp / path.c
1 /*
2  * File path.c - managing path in debugging environments
3  *
4  * Copyright (C) 2004, Eric Pouech
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library 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 GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <string.h>
25
26 #include "dbghelp_private.h"
27 #include "wine/debug.h"
28
29 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
30
31 /******************************************************************
32  *              FindDebugInfoFile (DBGHELP.@)
33  *
34  */
35 HANDLE WINAPI FindDebugInfoFile(PSTR FileName, PSTR SymbolPath, PSTR DebugFilePath)
36 {
37     HANDLE      h;
38
39     h = CreateFileA(DebugFilePath, GENERIC_READ, FILE_SHARE_READ, NULL,
40                     OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
41     if (h == INVALID_HANDLE_VALUE)
42     {
43         const char* p = strrchr(FileName, '/');
44         if (!p) p = FileName;
45         if (!SearchPathA(SymbolPath, p, NULL, MAX_PATH, DebugFilePath, NULL))
46             return NULL;
47         h = CreateFileA(DebugFilePath, GENERIC_READ, FILE_SHARE_READ, NULL,
48                         OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
49     }
50     return (h == INVALID_HANDLE_VALUE) ? NULL : h;
51 }
52  
53 /******************************************************************
54  *              FindDebugInfoFileEx (DBGHELP.@)
55  *
56  */
57 HANDLE WINAPI FindDebugInfoFileEx(PSTR FileName, PSTR SymbolPath,
58                                   PSTR DebugFilePath, 
59                                   PFIND_DEBUG_FILE_CALLBACK Callback,
60                                   PVOID CallerData)
61 {
62     FIXME("(%s %s %p %p %p): stub\n", 
63           FileName, SymbolPath, DebugFilePath, Callback, CallerData);
64     return NULL;
65 }
66
67 /******************************************************************
68  *              FindExecutableImage (DBGHELP.@)
69  *
70  */
71 HANDLE WINAPI FindExecutableImage(PSTR FileName, PSTR SymbolPath, PSTR ImageFilePath)
72 {
73     HANDLE h;
74     if (!SearchPathA(SymbolPath, FileName, NULL, MAX_PATH, ImageFilePath, NULL))
75         return NULL;
76     h = CreateFileA(ImageFilePath, GENERIC_READ, FILE_SHARE_READ, NULL, 
77                     OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
78     return (h == INVALID_HANDLE_VALUE) ? NULL : h;
79 }
80
81 /***********************************************************************
82  *           MakeSureDirectoryPathExists (DBGHELP.@)
83  */
84 BOOL WINAPI MakeSureDirectoryPathExists(LPCSTR DirPath)
85 {
86     if (CreateDirectoryA(DirPath, NULL)) return TRUE;
87     if (GetLastError() == ERROR_ALREADY_EXISTS)
88     {
89         SetLastError(ERROR_SUCCESS);
90         return TRUE;
91     }
92     return FALSE;
93 }
94
95 /***********************************************************************
96  *           SearchTreeForFile (DBGHELP.@)
97  */
98 BOOL WINAPI SearchTreeForFile(LPSTR RootPath, LPSTR InputPathName, 
99                               LPSTR OutputPathBuffer)
100 {
101     FIXME("(%s, %s, %s): stub\n",
102           debugstr_a(RootPath), debugstr_a(InputPathName),
103           debugstr_a(OutputPathBuffer));
104     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
105     return FALSE;
106 }