00001
00002
00003
00004
00005
00006 #include "vmsFile.h"
00007
00008 vmsFile::vmsFile()
00009 {
00010 m_file = NULL;
00011 }
00012
00013 vmsFile::~vmsFile()
00014 {
00015 close ();
00016 }
00017
00018 bool vmsFile::open(LPCSTR pszName, LPCSTR pszMode)
00019 {
00020 close ();
00021
00022 m_file = fopen (pszName, pszMode);
00023
00024 return m_file != NULL;
00025 }
00026
00027 void vmsFile::close()
00028 {
00029 if (m_file)
00030 {
00031 fclose (m_file);
00032 m_file = NULL;
00033 }
00034 }
00035
00036 bool vmsFile::read(std::string& str)
00037 {
00038 char sz [1000] = "";
00039 str = "";
00040
00041 for (;;)
00042 {
00043 LPCSTR psz = fgets (sz, sizeof (sz) - 1, m_file);
00044
00045 if (psz == NULL && !feof (m_file))
00046 {
00047 str = "";
00048 return false;
00049 }
00050
00051 if (psz == NULL)
00052 return false;
00053
00054 str += sz;
00055 if (lstrlen (sz) < sizeof (sz) - 1 ||
00056 str [str.length () - 1] == '\n')
00057 break;
00058 };
00059
00060 if (str [str.length () - 1] == '\n')
00061 str.erase (str.begin () + str.length () - 1);
00062
00063 return true;
00064 }