~ubuntu-branches/ubuntu/quantal/gputils/quantal

« back to all changes in this revision

Viewing changes to libgputils/gpsystem.c

  • Committer: Bazaar Package Importer
  • Author(s): Aurelien Jarno
  • Date: 2005-04-16 01:00:23 UTC
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20050416010023-xo612jqs8xlk0b3d
Tags: upstream-0.13.1
ImportĀ upstreamĀ versionĀ 0.13.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* General system functions
2
 
   Copyright (C) 2003, 2004
 
2
   Copyright (C) 2003, 2004, 2005
3
3
   Craig Franklin
4
4
 
5
5
This file is part of gputils.
22
22
#include "stdhdr.h"
23
23
#include "libgputils.h"
24
24
 
 
25
#ifdef HAVE_WINDOWS_H
 
26
#include <windows.h>
 
27
#endif
 
28
 
25
29
char *gp_header_path;
26
30
char *gp_lkr_path;
27
31
char *gp_lib_path;
28
32
char *gp_pub_path;
29
33
 
 
34
gp_boolean absolute_path_warning = true;
 
35
 
30
36
/* initialize the library */
31
37
 
32
38
void
251
257
{
252
258
  return link->annotation;
253
259
}
 
260
 
 
261
/* fetch the absolute path of the filename */
 
262
char *
 
263
gp_absolute_path(char *file_name)
 
264
{
 
265
#ifdef HAVE_WINDOWS_H
 
266
 
 
267
  /* It would be better to test for GetFullPathName, but the test won't
 
268
     work with a cross compiler. So if windows.h exists, we assume that
 
269
     GetFullPathName is available. */ 
 
270
 
 
271
  #define FILE_BUFFER_SIZE 512
 
272
  char file_buffer[FILE_BUFFER_SIZE];
 
273
  char *file_ptr;
 
274
  int num_chars;
 
275
 
 
276
  num_chars = GetFullPathName(file_name, 
 
277
                              FILE_BUFFER_SIZE,
 
278
                              file_buffer,
 
279
                              &file_ptr);
 
280
  if (num_chars == 0) {
 
281
    gp_error("can't fetch full path of %s", file_name);
 
282
    return file_name;
 
283
  } else {
 
284
    return strdup(file_buffer);
 
285
  }
 
286
#else
 
287
 
 
288
  if (absolute_path_warning) {
 
289
    gp_warning("host system does not support absolute paths");
 
290
    absolute_path_warning = false;
 
291
  }
 
292
  
 
293
  return file_name;
 
294
 
 
295
#endif
 
296
}