PageRenderTime 38ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Doc/Devel/file.html

#
HTML | 181 lines | 141 code | 40 blank | 0 comment | 0 complexity | 9ffcdf10c1e56738d226050fc67eba8c MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. <html>
  2. <head>
  3. <title>SWIG File Handling</title>
  4. </head>
  5. <body>
  6. <center>
  7. <h1>SWIG File Handling</h1>
  8. <p>
  9. David M. Beazley <br>
  10. dave-swig@dabeaz.com<br>
  11. December, 2006<br>
  12. </b>
  13. </center>
  14. <h2>Introduction</h2>
  15. This document describes the functions related to file and filename handling in the SWIG core. These functions are
  16. defined in the header file <tt>Source/Swig/swigfile.h</tt>. This API is considered to be stable.
  17. <h2>File Search Path</h2>
  18. These functions manipulate the search path for locating files.
  19. <p>
  20. <b><tt>List *Swig_add_directory(const String_or_char *dirname)</tt></b>
  21. <blockquote>
  22. Adds a new directory to the system search path. The directory is appended to
  23. the end of the search path. Returns a list containing the current
  24. system search path.
  25. </blockquote>
  26. <p>
  27. <b><tt>void Swig_push_directory(const String_or_char *dirname)</tt></b>
  28. <blockquote>
  29. Pushes a temporary directory onto the search path. This directory is searched before
  30. directories added with <tt>Swig_add_directory()</tt> except when including a system
  31. file explicitly (either using #include &lt;file&gt; or calling <tt>Swig_include_sys()</tt>).
  32. This function is normally used by the preprocessor to add temporary directories when
  33. processing #include statements.
  34. </blockquote>
  35. <p>
  36. <b><tt>void Swig_pop_directory()</tt></b>
  37. <blockquote>
  38. Pops off the last pushed directory with <tt>Swig_push_directory()</tt>
  39. </blockquote>
  40. <p>
  41. <b><tt>int Swig_get_push_dir()</tt></b>
  42. <blockquote>
  43. Returns a flag that indicates whether directory pushing is enabled or not.
  44. </blockquote>
  45. <p>
  46. <b><tt>void Swig_set_push_dir(int dopush)</tt></b>
  47. <blockquote>
  48. Enables or disables directory pushing. By default, it is turned on. However, the <tt>-I-</tt> command line
  49. option to SWIG disables it.
  50. </blockquote>
  51. <p>
  52. <b><tt>List *Swig_search_path()</tt></b>
  53. <blockquote>
  54. Returns the current search path.
  55. </blockquote>
  56. <h2>File access functions</h2>
  57. <p>
  58. <b><tt>FILE *Swig_open(const String_or_char *name)</tt></b>
  59. <blockquote>
  60. Opens a file, using the applicable search paths, and returns an open <tt>FILE *</tt> object if found. Returns NULL if the file is not found.
  61. </blockquote>
  62. <p>
  63. <b><tt>String *Swig_read_file(FILE *f)</tt></b>
  64. <blockquote>
  65. Reads all of the data from an open file into a string which is returned.
  66. </blockquote>
  67. <p>
  68. <b><tt>String *Swig_include(const String_or_char *name)</tt></b>
  69. <blockquote>
  70. Searches for an include file <tt>name</tt> and returns its contents as
  71. a string if found. Returns NULL if not found. All of the applicable
  72. search paths are searched when trying to locate the file.
  73. </blockquote>
  74. <p>
  75. <b><tt>String *Swig_include_sys(const String_or_char *name)</tt></b>
  76. <blockquote>
  77. Searches for an include file <tt>name</tt> and returns its contents as
  78. a string if found. Returns NULL if not found. All of the applicable
  79. search paths are searched when trying to locate the file, but
  80. preference is given to system paths first. This mimics the behavior
  81. of <tt>#include &lt;file&gt;</tt> in the preprocessor.
  82. </blockquote>
  83. <p>
  84. <b><tt>int Swig_insert_file(const String_or_char *name, File *outfile)</tt></b>
  85. <blockquote>
  86. Searches for a file <tt>name</tt> and dumps its contents to <tt>outfile</tt> if found.
  87. Returns 0 on success, -1 if the file couldn't be found.
  88. </blockquote>
  89. <h2>Query functions</h2>
  90. <p>
  91. <b><tt>String *Swig_last_file()</tt></b>
  92. <blockquote>
  93. Returns the full pathname of the file last opened or included.
  94. </blockquote>
  95. <h2>Named files</h2>
  96. <p>
  97. <b><tt>void *Swig_register_filebyname(const String_or_char *filename, File *outfile)</tt></b>
  98. <blockquote>
  99. Registers a file object <tt>outfile</tt> with a specific name <tt>filename</tt>. This function is
  100. used to implement the SWIG %insert directive and to manage different sections of the output
  101. file such as "runtime","header","wrapper","init", etc. Different language modules may add their own
  102. sections for generating Python code, Perl code, etc.
  103. </blockquote>
  104. <p>
  105. <b><tt>File *Swig_filebyname(const String_or_char *filename)</tt></b>
  106. <blockquote>
  107. This looks up a file object previously registered using <tt>Swig_register_filebyname()</tt>. This
  108. is used to implement the %insert directive.
  109. </blockquote>
  110. <h2>Filename utilities</h2>
  111. <p>
  112. <b><tt>char *Swig_file_suffix(const String_or_char *filename)</tt></b>
  113. <blockquote>
  114. Returns the suffix of a filename. For instance, if the filename is "foo.txt", it returns ".txt".
  115. </blockquote>
  116. <p>
  117. <b><tt>char *Swig_file_basename(const String_or_char *filename)</tt></b>
  118. <blockquote>
  119. Returns the filename without the suffix attached to it. For instance, if the filename is "foo.txt", it returns
  120. "foo". The result is stored in a static variable. If you need to save it, make your own copy.
  121. </blockquote>
  122. <p>
  123. <b><tt>char *Swig_file_filename(const String_or_char *filename)</tt></b>
  124. <blockquote>
  125. Returns the filename without any leading directories. For instance, if the filename is "/bar/spam/foo.txt", it
  126. returns "foo.txt". This function is aware of local naming conventions on the machine (e.g., forward versus back slashes on Unix and Windows). The result is stored in a static variable. If you need to save the value, make a copy.
  127. </blockquote>
  128. <p>
  129. <b><tt>char *Swig_file_dirname(const String_or_char *filename)</tt></b>
  130. <blockquote>
  131. Returns the directory name (if any). For instance, if the filename is "/bar/spam/foo.txt", it
  132. returns "/bar/spam/". This function is aware of local naming conventions on the machine (e.g., forward versus back slashes on Unix and Windows). The result is stored in a static variable. If you need to save the value, make a copy.
  133. </blockquote>
  134. <p>
  135. <b><tt>SWIG_FILE_DELIMITER</tt></b>
  136. <blockquote>
  137. This macro contains the file delimiter string for the local machine. On Unix it is "/", on Windows it is "\\".
  138. </blockquote>
  139. </body>
  140. </html>