~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/blenlib/intern/winstuff.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2007-05-17 11:47:59 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517114759-yp4ybrnhp2u7pk66
Tags: 2.44-1
* New upstream release.
* Drop debian/patches/01_64bits_stupidity, not needed anymore: as of this
  version blender is 64 bits safe again. Adjust README.Debian accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
 * $Id: winstuff.c,v 1.12 2006/08/20 14:41:13 elubie Exp $
 
2
 * $Id: winstuff.c,v 1.13 2007/02/28 20:11:10 elubie Exp $
3
3
 *
4
4
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5
5
 *
150
150
}
151
151
 
152
152
void get_default_root(char* root) {
153
 
        DWORD tmp;
154
 
        int i;
155
 
 
156
 
        tmp= GetLogicalDrives();
157
 
 
158
 
        for (i=2; i < 26; i++) {
159
 
                if ((tmp>>i) & 1) {
160
 
                        root[0] = 'a'+i;
 
153
        char str[MAX_PATH+1];
 
154
        
 
155
        /* the default drive to resolve a directory without a specified drive 
 
156
           should be the Windows installation drive, since this was what the OS
 
157
           assumes. */
 
158
        if (GetWindowsDirectory(str,MAX_PATH+1)) {
 
159
                root[0] = str[0];
 
160
                root[1] = ':';
 
161
                root[2] = '\\';
 
162
                root[3] = '\0';
 
163
        } else {                
 
164
                /* if GetWindowsDirectory fails, something has probably gone wrong, 
 
165
                   we are trying the blender install dir though */
 
166
                if (GetModuleFileName(NULL,str,MAX_PATH+1)) {
 
167
                        printf("Error! Could not get the Windows Directory - Defaulting to Blender installation Dir!");
 
168
                        root[0] = str[0];
161
169
                        root[1] = ':';
162
170
                        root[2] = '\\';
163
171
                        root[3] = '\0';
164
 
                        if (GetFileAttributes(root) != 0xFFFFFFFF)
165
 
                                return;                 
166
 
                }
 
172
                } else {
 
173
                        DWORD tmp;
 
174
                        int i;
 
175
                        int rc = 0;
 
176
                        /* now something has gone really wrong - still trying our best guess */
 
177
                        printf("Error! Could not get the Windows Directory - Defaulting to first valid drive! Path might be invalid!");
 
178
                        tmp= GetLogicalDrives();
 
179
                        for (i=2; i < 26; i++) {
 
180
                                if ((tmp>>i) & 1) {
 
181
                                        root[0] = 'a'+i;
 
182
                                        root[1] = ':';
 
183
                                        root[2] = '\\';
 
184
                                        root[3] = '\0';
 
185
                                        if (GetFileAttributes(root) != 0xFFFFFFFF) {
 
186
                                                rc = i;
 
187
                                                break;                  
 
188
                                        }
 
189
                                }
 
190
                        }
 
191
                        if (0 == rc) {
 
192
                                printf("ERROR in 'get_default_root': can't find a valid drive!");
 
193
                                root[0] = 'C';
 
194
                                root[1] = ':';
 
195
                                root[2] = '\\';
 
196
                                root[3] = '\0';
 
197
                        }
 
198
                }               
167
199
        }
168
 
 
169
 
        printf("ERROR in 'get_default_root': can't find a valid drive!");
170
 
        root[0] = 'c';
171
 
        root[1] = ':';
172
 
        root[2] = '\\';
173
 
        root[3] = '\0';
174
200
}
175
201
 
176
202
#else