File indexing completed on 2024-04-28 16:08:40
0001 /*************************************************************************** 0002 * Copyright (C) 2005-2014 by Linuxstopmotion contributors; * 0003 * see the AUTHORS file for details. * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 #ifndef UTIL_H 0021 #define UTIL_H 0022 0023 #include <exception> 0024 #include <string> 0025 #include <vector> 0026 0027 struct GrabberDevice { 0028 std::string device; 0029 std::string name; 0030 std::string type; 0031 }; 0032 0033 class FileLinkException : public std::exception { 0034 char msg[100]; 0035 public: 0036 FileLinkException(const char* message); 0037 const char* what() const throw(); 0038 }; 0039 0040 class DirectoryCreationException : public std::exception { 0041 char buffer[1024]; 0042 public: 0043 DirectoryCreationException(const char* path); 0044 const char* what() const throw(); 0045 }; 0046 0047 class Util { 0048 public: 0049 /** 0050 * Finds the end of the first segment of a bash command-line argument. 0051 * This is usually the first space, but can be later in the presence of 0052 * quotes or backslashes. Called on a full command line, it will find the 0053 * end of the command, which will be a space, tab or the end of the line. 0054 * @param in The command line to check. Ownership is not passed. 0055 * @return The rest of the string after the first segment. 0056 */ 0057 static const char* endOfArgument(const char* in); 0058 static bool checkCommand(std::string* pathOut, const char* command); 0059 static const std::vector<GrabberDevice> getGrabberDevices(); 0060 static bool copyFile(const char *destFileName, const char *srcFileName); 0061 static void linkOrCopyFile(const char *newName, const char* oldName); 0062 static bool removeDirectoryContents(const char* path); 0063 static void ensurePathExists(const char* path); 0064 }; 0065 0066 #endif 0067