[colobot] 127/377: Moving global files function from CBot.cpp to CBotFileUtils.cpp

Didier Raboud odyx at moszumanska.debian.org
Wed Mar 30 13:34:06 UTC 2016


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch debian/master
in repository colobot.

commit 43ac0e35f2b3c5d66738e3dd035080927d0ecb23
Author: Grunaka <dev at romainbreton.fr>
Date:   Sun Nov 22 16:04:38 2015 +0100

    Moving global files function from CBot.cpp to CBotFileUtils.cpp
---
 src/CBot/CBot.cpp                               | 40 --------------
 src/CBot/CBotDll.h                              |  7 ---
 src/CBot/CBotFileUtils.cpp                      | 62 +++++++++++++++++++++
 src/CBot/CBotFileUtils.h                        | 71 +++++++++++++++++++++++++
 src/CBot/CMakeLists.txt                         |  3 +-
 src/level/robotmain.cpp                         |  1 +
 src/object/implementation/programmable_impl.cpp |  2 +
 src/script/script.cpp                           |  1 +
 8 files changed, 139 insertions(+), 48 deletions(-)

diff --git a/src/CBot/CBot.cpp b/src/CBot/CBot.cpp
index da8109f..52ea9c6 100644
--- a/src/CBot/CBot.cpp
+++ b/src/CBot/CBot.cpp
@@ -83,43 +83,3 @@
 // Global include
 #include <cassert>
 
-/////////////////////////////////////////////////////////////////////////////////////
-// file management
-
-// necessary because it is not possible to do the fopen in the main program
-// fwrite and fread in a dll or using the FILE * returned.
-
-
-FILE* fOpen(const char* name, const char* mode)
-{
-    return fopen(name, mode);
-}
-
-int fClose(FILE* filehandle)
-{
-    return fclose(filehandle);
-}
-
-size_t fWrite(const void *buffer, size_t elemsize, size_t length, FILE* filehandle)
-{
-    return fwrite(buffer, elemsize, length, filehandle);
-}
-
-size_t fRead(void *buffer, size_t elemsize, size_t length, FILE* filehandle)
-{
-    return fread(buffer, elemsize, length, filehandle);
-}
-
-size_t fWrite(const void *buffer, size_t length, FILE* filehandle)
-{
-    return fwrite(buffer, 1, length, filehandle);
-}
-
-size_t fRead(void *buffer, size_t length, FILE* filehandle)
-{
-    return fread(buffer, 1, length, filehandle);
-}
-
-
-////////////////////////////////////////
-
diff --git a/src/CBot/CBotDll.h b/src/CBot/CBotDll.h
index fd5939d..d1d1838 100644
--- a/src/CBot/CBotDll.h
+++ b/src/CBot/CBotDll.h
@@ -147,13 +147,6 @@ class CBotCStack;       // stack
 // for example exceptions returned by external routines
 // and " throw " with any number.
 
-///////////////////////////////////////////////////////////////////////////////
-// routines for file management  (* FILE)
-    FILE*        fOpen(const char* name, const char* mode);
-    int            fClose(FILE* filehandle);
-    size_t        fWrite(const void *buffer, size_t elemsize, size_t length, FILE* filehandle);
-    size_t        fRead(void *buffer, size_t elemsize, size_t length, FILE* filehandle);
-
 
 #if 0
 /*
diff --git a/src/CBot/CBotFileUtils.cpp b/src/CBot/CBotFileUtils.cpp
new file mode 100644
index 0000000..1c58571
--- /dev/null
+++ b/src/CBot/CBotFileUtils.cpp
@@ -0,0 +1,62 @@
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsitec.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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, see http://gnu.org/licenses
+ */
+
+// Modules inlcude
+#include "CBotFileUtils.h"
+
+// Local include
+
+// Global include
+
+
+
+// file management
+
+// necessary because it is not possible to do the fopen in the main program
+// fwrite and fread in a dll or using the FILE * returned.
+
+////////////////////////////////////////////////////////////////////////////////
+FILE* fOpen(const char* name, const char* mode)
+{
+    return fopen(name, mode);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int fClose(FILE* filehandle)
+{
+    return fclose(filehandle);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::size_t fWrite(const void *buffer,
+                   std::size_t elemsize,
+                   std::size_t length,
+                   FILE* filehandle)
+{
+    return fwrite(buffer, elemsize, length, filehandle);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::size_t fRead(void *buffer,
+                  std::size_t elemsize,
+                  std::size_t length,
+                  FILE* filehandle)
+{
+    return fread(buffer, elemsize, length, filehandle);
+}
diff --git a/src/CBot/CBotFileUtils.h b/src/CBot/CBotFileUtils.h
new file mode 100644
index 0000000..8f76ec4
--- /dev/null
+++ b/src/CBot/CBotFileUtils.h
@@ -0,0 +1,71 @@
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsitec.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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, see http://gnu.org/licenses
+ */
+
+#pragma once
+
+// Modules inlcude
+
+// Local include
+
+// Global include
+ #include <cstdio>
+
+///////////////////////////////////////////////////////////////////////////////
+// routines for file management  (* FILE)
+
+/*!
+ * \brief fOpen
+ * \param name
+ * \param mode
+ * \return
+ */
+FILE* fOpen(const char* name, const char* mode);
+
+/*!
+ * \brief fClose
+ * \param filehandle
+ * \return
+ */
+int fClose(FILE* filehandle);
+
+/*!
+ * \brief fWrite
+ * \param buffer
+ * \param elemsize
+ * \param length
+ * \param filehandle
+ * \return
+ */
+std::size_t fWrite(const void *buffer,
+                   std::size_t elemsize,
+                   std::size_t length,
+                   FILE* filehandle);
+
+/*!
+ * \brief fRead
+ * \param buffer
+ * \param elemsize
+ * \param length
+ * \param filehandle
+ * \return
+ */
+std::size_t fRead(void *buffer,
+                  std::size_t elemsize,
+                  std::size_t length,
+                  FILE* filehandle);
diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt
index e2fa17c..3bb1eb9 100644
--- a/src/CBot/CMakeLists.txt
+++ b/src/CBot/CMakeLists.txt
@@ -1,5 +1,7 @@
 set(SOURCES
     CBot.cpp
+    CBotUtils.cpp
+    CBotFileUtils.cpp
     CBotClass.cpp
     CBotProgram.cpp
     CBotStack.cpp
@@ -7,7 +9,6 @@ set(SOURCES
     CBotString.cpp
     CBotToken.cpp
     CBotCall.cpp
-    CBotUtils.cpp
     CBotDefParam.cpp
     CBotCallMethode.cpp
     CBotStringArray.cpp
diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp
index 8ff82ee..7cd1bdb 100644
--- a/src/level/robotmain.cpp
+++ b/src/level/robotmain.cpp
@@ -20,6 +20,7 @@
 #include "level/robotmain.h"
 
 #include "CBot/CBotDll.h"
+#include "CBot/CBotFileUtils.h"
 // TODO must be replaced by CBot.h
 #include "CBot/CBotClass.h"
 
diff --git a/src/object/implementation/programmable_impl.cpp b/src/object/implementation/programmable_impl.cpp
index fe594e7..379929e 100644
--- a/src/object/implementation/programmable_impl.cpp
+++ b/src/object/implementation/programmable_impl.cpp
@@ -40,6 +40,8 @@
 
 #include "ui/controls/edit.h"
 
+#include "CBot/CBotFileUtils.h"
+
 #include <algorithm>
 #include <iomanip>
 
diff --git a/src/script/script.cpp b/src/script/script.cpp
index d87a41a..92c658f 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -44,6 +44,7 @@
 
 #include "CBot/CBotToken.h"
 #include "CBot/CBotVar/CBotVar.h"
+#include "CBot/CBotFileUtils.h"
 
 
 const int CBOT_IPF = 100;       // CBOT: default number of instructions / frame

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git



More information about the Pkg-games-commits mailing list