extras/abs-file.h
changeset 562 1e307df36810
parent 512 5ed9ffa3ad8f
child 578 bff1af8455ca
equal deleted inserted replaced
561:c8fe65f89fb9 562:1e307df36810
     1 /*
     1 /*
     2  * stdio/physfs abstraction layer 2002-12-03
     2  * stdio/physfs abstraction layer 2003-04-02
     3  *
     3  *
     4  * Adam D. Moss <adam@gimp.org> <aspirin@icculus.org>
     4  * Adam D. Moss <adam@gimp.org> <aspirin@icculus.org>
     5  *
     5  *
     6  * These wrapper macros and functions are designed to allow a program
     6  * These wrapper macros and functions are designed to allow a program
     7  * to perform file I/O with identical semantics and syntax regardless
     7  * to perform file I/O with identical semantics and syntax regardless
    13 PLEASE NOTE: This license applies to abs-file.h ONLY (to make it clear that
    13 PLEASE NOTE: This license applies to abs-file.h ONLY (to make it clear that
    14 you may embed this wrapper code within commercial software); PhysicsFS itself
    14 you may embed this wrapper code within commercial software); PhysicsFS itself
    15 is (at the time of writing) released under a different license with
    15 is (at the time of writing) released under a different license with
    16 additional restrictions.
    16 additional restrictions.
    17 
    17 
    18 Copyright (C) 2002 Adam D. Moss (the "Author").  All Rights Reserved.
    18 Copyright (C) 2002-2003 Adam D. Moss (the "Author").  All Rights Reserved.
    19 
    19 
    20 Permission is hereby granted, free of charge, to any person obtaining a copy
    20 Permission is hereby granted, free of charge, to any person obtaining a copy
    21 of this software and associated documentation files (the "Software"), to deal
    21 of this software and associated documentation files (the "Software"), to deal
    22 in the Software without restriction, including without limitation the rights
    22 in the Software without restriction, including without limitation the rights
    23 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    23 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    53  * MY_READ              fread(...)
    53  * MY_READ              fread(...)
    54  * MY_CLOSE             fclose(...)
    54  * MY_CLOSE             fclose(...)
    55  * MY_GETC              fgetc(...)
    55  * MY_GETC              fgetc(...)
    56  * MY_GETS              fgets(...)
    56  * MY_GETS              fgets(...)
    57  * MY_ATEOF             feof(...)
    57  * MY_ATEOF             feof(...)
       
    58  * MY_TELL              ftell(...)
       
    59  * MY_SEEK              fseek(..., SEEK_SET)
    58  * MY_REWIND            rewind(...)
    60  * MY_REWIND            rewind(...)
    59  * MY_SETBUFFER         (not a standard for stdio, does nothing there)
    61  * MY_SETBUFFER         (not a standard for stdio, does nothing there)
    60  */
    62  */
    61 
    63 
    62 /*
    64 /*
   138   }
   140   }
   139   return str;
   141   return str;
   140 }
   142 }
   141 #define MY_CLOSE(fp) PHYSFS_close(fp)
   143 #define MY_CLOSE(fp) PHYSFS_close(fp)
   142 #define MY_ATEOF(fp) PHYSFS_eof(fp)
   144 #define MY_ATEOF(fp) PHYSFS_eof(fp)
   143 #define MY_REWIND(fp) PHYSFS_seek(fp,0)
   145 #define MY_TELL(fp) PHYSFS_tell(fp)
       
   146 #define MY_SEEK(fp,o) PHYSFS_seek(fp,o)
       
   147 #define MY_REWIND(fp) MY_SEEK(fp,0)
   144 
   148 
   145 #else
   149 #else
   146 
   150 
   147 #define MY_FILETYPE FILE
   151 #define MY_FILETYPE FILE
   148 #define MY_READ(p,s,n,fp) fread(p,s,n,fp)
   152 #define MY_READ(p,s,n,fp) fread(p,s,n,fp)
   149 #define MY_OPEN_FOR_READ(n) fopen(n, "rb")
   153 #define MY_OPEN_FOR_READ(n) fopen(n, "rb")
   150 #define MY_GETC(fp) fgetc(fp)
   154 #define MY_GETC(fp) fgetc(fp)
   151 #define MY_GETS(str,size,fp) fgets(str,size,fp)
   155 #define MY_GETS(str,size,fp) fgets(str,size,fp)
   152 #define MY_CLOSE(fp) fclose(fp)
   156 #define MY_CLOSE(fp) fclose(fp)
   153 #define MY_ATEOF(fp) feof(fp)
   157 #define MY_ATEOF(fp) feof(fp)
       
   158 #define MY_TELL(fp) ftell(fp)
       
   159 #define MY_SEEK(fp,o) fseek(fp,o, SEEK_SET)
   154 #define MY_REWIND(fp) rewind(fp)
   160 #define MY_REWIND(fp) rewind(fp)
   155 static void MY_SETBUFFER(const MY_FILETYPE *const file, const int num) { }
   161 /*static void MY_SETBUFFER(const MY_FILETYPE *const file, const int num) { }*/
       
   162 #define MY_SETBUFFER(fp,size)
   156 #endif
   163 #endif
   157 
   164 
   158 #endif
   165 #endif