home *** CD-ROM | disk | FTP | other *** search
- /*-- Rev Header - do NOT edit!
- *
- * Filename : getfilesize1.cc
- * Purpose : Gibt Länge eines Files(Filename) zurück, oder -1
- *
- * Program : -
- * Author : Gerhard Müller
- * Copyright: (c) by Gerhard Müller
- * Creation : Tue Sep 7 17:39:24 1993
- *
- * compile :
- *
- * Compile version : 0.1
- * Ext. Version : 0.1
- *
- * REVISION HISTORY
- *
- * Date Comment
- * ------------------------ -------------------------------------------------
- * Fri Sep 17 00:47:50 1993 Works
- *
- *-- REV_END --
- */
-
- /*
- * C-Includes, C-Definitionen
- *
- */
-
- #define class _class
- #define template _template
-
- extern "C" {
- #include <exec/types.h>
- #include <exec/execbase.h>
- #include <exec/memory.h>
- #include <clib/alib_protos.h>
- #include <clib/alib_stdio_protos.h>
- #include <inline/stubs.h>
- #include <dos/dos.h>
- #include <dos/dosextens.h>
- #ifdef __OPTIMIZE__
- #include <inline/exec.h>
- #include <inline/dos.h>
- #else
- #include <clib/exec_protos.h>
- #include <clib/dos_protos.h>
- #endif
- }
-
- #undef template
- #undef class
-
- /* GetFileSize(STRPTR Name):
- *
- * Simple routine to return the size of a file in
- * bytes.
- */
-
- LONG
- GetFileSize(STRPTR Name)
- {
- struct FileInfoBlock *FileInfo;
- LONG FileSize = -1;
-
- if(FileInfo = (struct FileInfoBlock *)AllocDosObject(DOS_FIB,TAG_DONE))
- {
- BPTR FileLock;
-
- if(FileLock = Lock(Name,ACCESS_READ))
- {
- if(Examine(FileLock,FileInfo))
- {
- if(FileInfo -> fib_DirEntryType < 0)
- FileSize = FileInfo -> fib_Size;
- }
-
- UnLock(FileLock);
- }
-
- FreeDosObject(DOS_FIB,FileInfo);
- }
-
- return(FileSize);
- }
-