src/core/system-file.h
changeset 150 663120712cd9
parent 131 f4fb87e77034
equal deleted inserted replaced
149:d5b12472c5e2 150:663120712cd9
     1 /* -*- Mode:NS3; -*- */
     1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
     2 /*
     2 /*
     3  * Copyright (c) 2005 INRIA
     3  * Copyright (c) 2005 INRIA
     4  * All rights reserved.
     4  * All rights reserved.
     5  *
     5  *
     6  * This program is free software; you can redistribute it and/or modify
     6  * This program is free software; you can redistribute it and/or modify
    33  *
    33  *
    34  * Create a file and write data to this file.
    34  * Create a file and write data to this file.
    35  */
    35  */
    36 class SystemFile {
    36 class SystemFile {
    37 public:
    37 public:
    38     /**
    38   /**
    39      * This method does not create or open any
    39    * This method does not create or open any
    40      * file on disk.
    40    * file on disk.
    41      */
    41    */
    42     SystemFile ();
    42   SystemFile ();
    43     /**
    43   /**
    44      * If a file has been opened, it is closed by
    44    * If a file has been opened, it is closed by
    45      * this destructor.
    45    * this destructor.
    46      */
    46    */
    47     ~SystemFile ();
    47   ~SystemFile ();
    48 
    48 
    49     /**
    49   /**
    50      * \param filename name of file to open
    50    * \param filename name of file to open
    51      *
    51    *
    52      * Open a file for writing. If the file does not
    52    * Open a file for writing. If the file does not
    53      * exist, it is created. If it exists, it is 
    53    * exist, it is created. If it exists, it is 
    54      * emptied first.
    54    * emptied first.
    55      */
    55    */
    56     void Open (char const *filename);
    56   void Open (char const *filename);
    57     /**
    57   /**
    58      * \param buffer data to write
    58    * \param buffer data to write
    59      * \param size size of data to write
    59    * \param size size of data to write
    60      *
    60    *
    61      * Write data in file on disk. This method cannot fail:
    61    * Write data in file on disk. This method cannot fail:
    62      * it will write _all_ the data to disk. This method does not
    62    * it will write _all_ the data to disk. This method does not
    63      * perform any data caching and forwards the data
    63    * perform any data caching and forwards the data
    64      * to the OS through a direct syscall. However, 
    64    * to the OS through a direct syscall. However, 
    65      * it is not possible to rely on the data being
    65    * it is not possible to rely on the data being
    66      * effectively written to disk after this method returns.
    66    * effectively written to disk after this method returns.
    67      * To make sure the data is written to disk, destroy 
    67    * To make sure the data is written to disk, destroy 
    68      * this object.
    68    * this object.
    69      */
    69    */
    70     void Write (uint8_t const*buffer, uint32_t size);
    70   void Write (uint8_t const*buffer, uint32_t size);
    71 private:
    71 private:
    72     SystemFilePrivate *m_priv;
    72   SystemFilePrivate *m_priv;
    73 };
    73 };
    74 
    74 
    75 }; //namespace ns3
    75 }; //namespace ns3
    76 
    76 
    77 #endif /* SYSTEM_FILE_H */
    77 #endif /* SYSTEM_FILE_H */