paragui-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paragui-cvs] CVS: paragui/test writefile.cpp,NONE,1.1.2.1 Makefile.am,1


From: Alexander Pipelka <address@hidden>
Subject: [paragui-cvs] CVS: paragui/test writefile.cpp,NONE,1.1.2.1 Makefile.am,1.2.6.7,1.2.6.8
Date: Fri, 12 Jul 2002 12:36:04 -0400

Update of /cvsroot/paragui/paragui/test
In directory subversions:/tmp/cvs-serv22362/test

Modified Files:
      Tag: devel-1-0
        Makefile.am 
Added Files:
      Tag: devel-1-0
        writefile.cpp 
Log Message:
added writefile sample

--- NEW FILE ---
/**********************************************************
This is a simple PG_File demo that writes 2 ints to a file
Roger D. Vargas
**********************************************************/
#include <pgfilearchive.h>
#include <pgfile.h>
#include <pglog.h>
#include <string>

int main() {
        PG_FileArchive *Arc;
        PG_File *wf;

        int v1=23444,v2=44566;

        // Create the FileArchive object
        Arc = new PG_FileArchive();

        // Set the base app dir as write dir
        Arc->SetWriteDir(PG_FileArchive::GetUserDir());

        // Now open a file for writing
        PG_LogMSG("creating writeable file ...");
        wf = Arc->OpenFile("pgtestfile", PG_OPEN_WRITE);

        // Write a line of text (CR will be added)
        wf->putline("test");

        //Now write a couple of ints
        wf->write(&v1,sizeof(v1));
        wf->write(&v2,sizeof(v2));

        // close file
        delete wf;

        // Open created file for reading
        PG_LogMSG("checking file ...");
        wf = Arc->OpenFile("pgtestfile", PG_OPEN_READ);

        // read and check the line of text
        std::string text = wf->getline();
        if(text != "test") {
                PG_LogERR("File corrupted (reading text failed)");
        }

        // read and check the ints
        int i=0;
        wf->read(&i, sizeof(i));
        if(i != v1) {
                PG_LogERR("File corrupted (reading int v1)");
        }

        wf->read(&i, sizeof(i));
        if(i != v2) {
                PG_LogERR("File corrupted (reading int v2)");
        }

        PG_LogMSG("check passed");

        // close file & archive
        delete wf;
        delete Arc;
}

Index: Makefile.am
===================================================================
RCS file: /cvsroot/paragui/paragui/test/Makefile.am,v
retrieving revision 1.2.6.7
retrieving revision 1.2.6.8
diff -C2 -r1.2.6.7 -r1.2.6.8
*** Makefile.am 12 Jul 2002 06:10:20 -0000      1.2.6.7
--- Makefile.am 12 Jul 2002 16:36:02 -0000      1.2.6.8
***************
*** 3,7 ****
  AUTOMAKE_OPTIONS = foreign
  
! bin_PROGRAMS = stress1 stress2 listbox animation dropdown paratest dblbuffer 
navtest windowtest layouttest windowresize
  
  stress1_SOURCES = stress1.cpp
--- 3,10 ----
  AUTOMAKE_OPTIONS = foreign
  
! bin_PROGRAMS = writefile stress1 stress2 listbox animation dropdown paratest 
dblbuffer navtest windowtest layouttest windowresize
! 
! writefile_SOURCES = writefile.cpp
! writefile_LDADD = -L../src $(PARAGUI_LIBS)
  
  stress1_SOURCES = stress1.cpp




reply via email to

[Prev in Thread] Current Thread [Next in Thread]