--- a/SConstruct Fri Mar 30 00:10:59 2007 +0200
+++ b/SConstruct Fri Mar 30 00:11:51 2007 +0200
@@ -32,15 +32,12 @@
core.add_external_dep('pthread')
core.add_sources([
'unix-system-wall-clock-ms.cc',
- 'unix-system-file.cc'
])
elif env['PLATFORM'] == 'win32':
core.add_sources([
'win32-system-wall-clock-ms.cc',
- 'win32-system-file.cc'
])
core.add_inst_headers([
- 'system-file.h',
'system-wall-clock-ms.h',
'reference-list.h',
'callback.h',
--- a/src/core/system-file.h Fri Mar 30 00:10:59 2007 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005 INRIA
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-
-#ifndef SYSTEM_FILE_H
-#define SYSTEM_FILE_H
-
-#include <stdint.h>
-
-namespace ns3 {
-
-class SystemFilePrivate;
-
-/**
- * \brief os-independent file creation and writing
- *
- * Create a file and write data to this file.
- */
-class SystemFile {
-public:
- /**
- * This method does not create or open any
- * file on disk.
- */
- SystemFile ();
- /**
- * If a file has been opened, it is closed by
- * this destructor.
- */
- ~SystemFile ();
-
- /**
- * \param filename name of file to open
- *
- * Open a file for writing. If the file does not
- * exist, it is created. If it exists, it is
- * emptied first.
- */
- void Open (char const *filename);
- /**
- * \param buffer data to write
- * \param size size of data to write
- *
- * Write data in file on disk. This method cannot fail:
- * it will write _all_ the data to disk. This method does not
- * perform any data caching and forwards the data
- * to the OS through a direct syscall. However,
- * it is not possible to rely on the data being
- * effectively written to disk after this method returns.
- * To make sure the data is written to disk, destroy
- * this object.
- */
- void Write (uint8_t const*buffer, uint32_t size);
-private:
- SystemFilePrivate *m_priv;
-};
-
-}; //namespace ns3
-
-#endif /* SYSTEM_FILE_H */
--- a/src/core/unix-system-file.cc Fri Mar 30 00:10:59 2007 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005 INRIA
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#include "system-file.h"
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/poll.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-#include <list>
-
-#include "assert.h"
-
-#define noTRACE_SYS_FILE 1
-
-#ifdef TRACE_SYS_FILE
-#include <iostream>
-# define TRACE(x) \
-std::cout << "SYS FILE TRACE " << this << " " << x << std::endl;
-#else /* TRACE_SYS_FILE */
-# define TRACE(format,...)
-#endif /* TRACE_SYS_FILE */
-
-#define BUFFER_SIZE (4096)
-
-
-namespace ns3 {
-
-class SystemFilePrivate {
-public:
- SystemFilePrivate ();
- ~SystemFilePrivate ();
-
- void Open (char const *filename);
- void Write (uint8_t const*buffer, uint32_t size);
-private:
- uint8_t m_data[BUFFER_SIZE];
- uint32_t m_current;
- int m_fd;
-};
-
-SystemFilePrivate::SystemFilePrivate ()
- : m_current (0)
-{}
-SystemFilePrivate::~SystemFilePrivate ()
-{
- ::write (m_fd, m_data, m_current);
- ::close (m_fd);
-}
-
-
-void
-SystemFilePrivate::Open (char const *filename)
-{
- m_fd = ::open (filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
- NS_ASSERT (m_fd != -1);
-}
-
-#ifndef min
-#define min(a,b) ((a)<(b)?(a):(b))
-#endif /* min */
-
-void
-SystemFilePrivate::Write (uint8_t const*buffer, uint32_t size)
-{
- while (size > 0)
- {
- uint32_t toCopy = min (BUFFER_SIZE - m_current, size);
- memcpy (m_data + m_current, buffer, toCopy);
- size -= toCopy;
- m_current += toCopy;
- buffer += toCopy;
- if (m_current == BUFFER_SIZE)
- {
- ssize_t written = 0;
- written = ::write (m_fd, m_data, BUFFER_SIZE);
- NS_ASSERT (written == BUFFER_SIZE);
- m_current = 0;
- }
- }
-}
-
-SystemFile::SystemFile ()
- : m_priv (new SystemFilePrivate ())
-{}
-SystemFile::~SystemFile ()
-{
- delete m_priv;
- m_priv = 0;
-}
-
-void
-SystemFile::Open (char const *filename)
-{
- m_priv->Open (filename);
-}
-void
-SystemFile::Write (uint8_t const*buffer, uint32_t size)
-{
- m_priv->Write (buffer, size);
-}
-
-}; // namespace
--- a/src/core/win32-system-file.cc Fri Mar 30 00:10:59 2007 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005 INRIA
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#include "system-file.h"
-
-
-#define noTRACE_SYS_FILE 1
-
-#ifdef TRACE_SYS_FILE
-#include <iostream>
-# define TRACE(x) \
-std::cout << "SYS FILE TRACE " << this << " " << x << std::endl;
-#else /* TRACE_SYS_FILE */
-# define TRACE(format,...)
-#endif /* TRACE_SYS_FILE */
-
-#define BUFFER_SIZE (4096)
-
-
-namespace ns3 {
-
-class SystemFilePrivate {
-public:
- SystemFilePrivate ();
- ~SystemFilePrivate ();
-
- void open (char const *filename);
- void write (uint8_t const*buffer, uint32_t size);
-private:
-};
-
-SystemFilePrivate::SystemFilePrivate ()
-{}
-SystemFilePrivate::~SystemFilePrivate ()
-{
-}
-
-
-void
-SystemFilePrivate::Open (char const *filename)
-{
-}
-
-void
-SystemFilePrivate::Write (uint8_t const*buffer, uint32_t size)
-{
-}
-
-SystemFile::SystemFile ()
- : m_priv (new SystemFilePrivate ())
-{}
-SystemFile::~SystemFile ()
-{
- delete m_priv;
- m_priv = 0;
-}
-
-void
-SystemFile::Open (char const *filename)
-{
- m_priv->Open (filename);
-}
-void
-SystemFile::Write (uint8_t const*buffer, uint32_t size)
-{
- m_priv->Write (buffer, size);
-}
-
-}; // namespace