mirror of
				https://gitlab.alpinelinux.org/alpine/aports.git
				synced 2025-11-04 10:21:36 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			277 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			277 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
Author: Patrycja Rosa <alpine@ptrcnull.me>
 | 
						|
Date: Thu, 03 Feb 2022 05:06:47 +0100
 | 
						|
 | 
						|
	replace throw with noexcept
 | 
						|
 | 
						|
	throw has been deprecated in C++11 and removed in C++17
 | 
						|
 | 
						|
diff --git a/conf.cc b/conf.cc
 | 
						|
index e9b596d..e537e00 100644
 | 
						|
--- a/conf.cc
 | 
						|
+++ b/conf.cc
 | 
						|
@@ -28,7 +28,7 @@
 | 
						|
 
 | 
						|
 using namespace std;
 | 
						|
 
 | 
						|
-static void expand_tree(const string& path, filepath_container& ds) throw (error)
 | 
						|
+static void expand_tree(const string& path, filepath_container& ds) noexcept (false)
 | 
						|
 {
 | 
						|
 	DIR* dir = opendir(path.c_str());
 | 
						|
 	if (!dir)
 | 
						|
diff --git a/file.cc b/file.cc
 | 
						|
index 1e90348..36f3495 100644
 | 
						|
--- a/file.cc
 | 
						|
+++ b/file.cc
 | 
						|
@@ -98,7 +98,7 @@ void infopath::readonly_set(bool Areadonly)
 | 
						|
 /**
 | 
						|
  * Check if a file exists.
 | 
						|
  */
 | 
						|
-bool file_exists(const string& path) throw (error)
 | 
						|
+bool file_exists(const string& path) noexcept (false)
 | 
						|
 {
 | 
						|
 	struct stat s;
 | 
						|
 	if (stat(path.c_str(), &s) != 0) {
 | 
						|
@@ -114,7 +114,7 @@ bool file_exists(const string& path) throw (error)
 | 
						|
 /**
 | 
						|
  * Write a whole file.
 | 
						|
  */
 | 
						|
-void file_write(const string& path, const char* data, unsigned size) throw (error)
 | 
						|
+void file_write(const string& path, const char* data, unsigned size) noexcept (false)
 | 
						|
 {
 | 
						|
 	FILE* f = fopen(path.c_str(), "wb");
 | 
						|
 	if (!f)
 | 
						|
@@ -134,7 +134,7 @@ void file_write(const string& path, const char* data, unsigned size) throw (erro
 | 
						|
 /**
 | 
						|
  * Read a whole file.
 | 
						|
  */
 | 
						|
-void file_read(const string& path, char* data, unsigned size) throw (error)
 | 
						|
+void file_read(const string& path, char* data, unsigned size) noexcept (false)
 | 
						|
 {
 | 
						|
 	file_read(path, data, 0, size);
 | 
						|
 }
 | 
						|
@@ -142,7 +142,7 @@ void file_read(const string& path, char* data, unsigned size) throw (error)
 | 
						|
 /**
 | 
						|
  * Read a whole file.
 | 
						|
  */
 | 
						|
-void file_read(const string& path, char* data, unsigned offset, unsigned size) throw (error)
 | 
						|
+void file_read(const string& path, char* data, unsigned offset, unsigned size) noexcept (false)
 | 
						|
 {
 | 
						|
 	FILE* f = fopen(path.c_str(), "rb");
 | 
						|
 	if (!f)
 | 
						|
@@ -166,7 +166,7 @@ void file_read(const string& path, char* data, unsigned offset, unsigned size) t
 | 
						|
 /**
 | 
						|
  * Get the time of a file.
 | 
						|
  */
 | 
						|
-time_t file_time(const string& path) throw (error)
 | 
						|
+time_t file_time(const string& path) noexcept (false)
 | 
						|
 {
 | 
						|
 	struct stat s;
 | 
						|
 	if (stat(path.c_str(), &s)!=0)
 | 
						|
@@ -178,7 +178,7 @@ time_t file_time(const string& path) throw (error)
 | 
						|
 /**
 | 
						|
  * Set the time of a file.
 | 
						|
  */
 | 
						|
-void file_utime(const string& path, time_t tod) throw (error)
 | 
						|
+void file_utime(const string& path, time_t tod) noexcept (false)
 | 
						|
 {
 | 
						|
 	struct utimbuf u;
 | 
						|
 
 | 
						|
@@ -192,7 +192,7 @@ void file_utime(const string& path, time_t tod) throw (error)
 | 
						|
 /**
 | 
						|
  * Get the size of a file.
 | 
						|
  */
 | 
						|
-unsigned file_size(const string& path) throw (error)
 | 
						|
+unsigned file_size(const string& path) noexcept (false)
 | 
						|
 {
 | 
						|
 	struct stat s;
 | 
						|
 	if (stat(path.c_str(), &s)!=0)
 | 
						|
@@ -204,7 +204,7 @@ unsigned file_size(const string& path) throw (error)
 | 
						|
 /**
 | 
						|
  * Get the crc of a file.
 | 
						|
  */
 | 
						|
-crc_t file_crc(const string& path) throw (error)
 | 
						|
+crc_t file_crc(const string& path) noexcept (false)
 | 
						|
 {
 | 
						|
 	unsigned size = file_size(path);
 | 
						|
 
 | 
						|
@@ -227,7 +227,7 @@ crc_t file_crc(const string& path) throw (error)
 | 
						|
 /**
 | 
						|
  * Copy a file.
 | 
						|
  */
 | 
						|
-void file_copy(const string& path1, const string& path2) throw (error)
 | 
						|
+void file_copy(const string& path1, const string& path2) noexcept (false)
 | 
						|
 {
 | 
						|
 	unsigned size;
 | 
						|
 
 | 
						|
@@ -249,7 +249,7 @@ void file_copy(const string& path1, const string& path2) throw (error)
 | 
						|
 /**
 | 
						|
  * Move a file.
 | 
						|
  */
 | 
						|
-void file_move(const string& path1, const string& path2) throw (error)
 | 
						|
+void file_move(const string& path1, const string& path2) noexcept (false)
 | 
						|
 {
 | 
						|
 	if (rename(path1.c_str(), path2.c_str())!=0
 | 
						|
 		&& errno==EXDEV) {
 | 
						|
@@ -271,7 +271,7 @@ void file_move(const string& path1, const string& path2) throw (error)
 | 
						|
 /**
 | 
						|
  * Remove a file.
 | 
						|
  */
 | 
						|
-void file_remove(const string& path1) throw (error)
 | 
						|
+void file_remove(const string& path1) noexcept (false)
 | 
						|
 {
 | 
						|
 	if (remove(path1.c_str())!=0) {
 | 
						|
 		throw error() << "Failed remove of " << path1;
 | 
						|
@@ -281,7 +281,7 @@ void file_remove(const string& path1) throw (error)
 | 
						|
 /**
 | 
						|
  * Rename a file.
 | 
						|
  */
 | 
						|
-void file_rename(const string& path1, const string& path2) throw (error)
 | 
						|
+void file_rename(const string& path1, const string& path2) noexcept (false)
 | 
						|
 {
 | 
						|
 	if (rename(path1.c_str(), path2.c_str())!=0) {
 | 
						|
 		throw error() << "Failed rename of " << path1 << " to " << path2;
 | 
						|
@@ -291,7 +291,7 @@ void file_rename(const string& path1, const string& path2) throw (error)
 | 
						|
 /**
 | 
						|
  * Randomize a name file.
 | 
						|
  */
 | 
						|
-string file_randomize(const string& path, int n) throw ()
 | 
						|
+string file_randomize(const string& path, int n) noexcept (true)
 | 
						|
 {
 | 
						|
 	ostringstream os;
 | 
						|
 
 | 
						|
@@ -307,7 +307,7 @@ string file_randomize(const string& path, int n) throw ()
 | 
						|
 	return os.str();
 | 
						|
 }
 | 
						|
 
 | 
						|
-string file_temp(const string& path) throw ()
 | 
						|
+string file_temp(const string& path) noexcept (true)
 | 
						|
 {
 | 
						|
 	ostringstream os;
 | 
						|
 
 | 
						|
@@ -319,7 +319,7 @@ string file_temp(const string& path) throw ()
 | 
						|
 /**
 | 
						|
  * Get the directory from a path.
 | 
						|
  */
 | 
						|
-string file_dir(const string& path) throw ()
 | 
						|
+string file_dir(const string& path) noexcept (true)
 | 
						|
 {
 | 
						|
 	size_t pos = path.rfind('/');
 | 
						|
 	if (pos == string::npos) {
 | 
						|
@@ -332,7 +332,7 @@ string file_dir(const string& path) throw ()
 | 
						|
 /**
 | 
						|
  * Get the file name from a path.
 | 
						|
  */
 | 
						|
-string file_name(const string& path) throw ()
 | 
						|
+string file_name(const string& path) noexcept (true)
 | 
						|
 {
 | 
						|
 	size_t pos = path.rfind('/');
 | 
						|
 	if (pos == string::npos) {
 | 
						|
@@ -345,7 +345,7 @@ string file_name(const string& path) throw ()
 | 
						|
 /**
 | 
						|
  * Get the basepath (path without extension) from a path.
 | 
						|
  */
 | 
						|
-string file_basepath(const string& path) throw ()
 | 
						|
+string file_basepath(const string& path) noexcept (true)
 | 
						|
 {
 | 
						|
 	size_t dot = path.rfind('.');
 | 
						|
 	if (dot == string::npos)
 | 
						|
@@ -357,7 +357,7 @@ string file_basepath(const string& path) throw ()
 | 
						|
 /**
 | 
						|
  * Get the basename (name without extension) from a path.
 | 
						|
  */
 | 
						|
-string file_basename(const string& path) throw ()
 | 
						|
+string file_basename(const string& path) noexcept (true)
 | 
						|
 { 
 | 
						|
 	string name = file_name(path);
 | 
						|
 	size_t dot = name.rfind('.');
 | 
						|
@@ -370,7 +370,7 @@ string file_basename(const string& path) throw ()
 | 
						|
 /**
 | 
						|
  * Get the extension from a path.
 | 
						|
  */
 | 
						|
-string file_ext(const string& path) throw ()
 | 
						|
+string file_ext(const string& path) noexcept (true)
 | 
						|
 { 
 | 
						|
 	string name = file_name(path);
 | 
						|
 	size_t dot = name.rfind('.');
 | 
						|
@@ -383,7 +383,7 @@ string file_ext(const string& path) throw ()
 | 
						|
 /**
 | 
						|
  * Compare two path.
 | 
						|
  */
 | 
						|
-int file_compare(const string& path1, const string& path2) throw ()
 | 
						|
+int file_compare(const string& path1, const string& path2) noexcept (true)
 | 
						|
 {
 | 
						|
 	return strcasecmp(path1.c_str(), path2.c_str());
 | 
						|
 }
 | 
						|
@@ -391,7 +391,7 @@ int file_compare(const string& path1, const string& path2) throw ()
 | 
						|
 /**
 | 
						|
  * Convert a path to the C format.
 | 
						|
  */
 | 
						|
-string file_adjust(const string& path) throw ()
 | 
						|
+string file_adjust(const string& path) noexcept (true)
 | 
						|
 {
 | 
						|
 	string r;
 | 
						|
 	for(unsigned i=0;i<path.length();++i) {
 | 
						|
@@ -409,7 +409,7 @@ string file_adjust(const string& path) throw ()
 | 
						|
 /**
 | 
						|
  * Make a drectory tree.
 | 
						|
  */
 | 
						|
-void file_mktree(const std::string& path) throw (error)
 | 
						|
+void file_mktree(const std::string& path) noexcept (false)
 | 
						|
 {
 | 
						|
 	string dir = file_dir(path);
 | 
						|
 	string name = file_name(path);
 | 
						|
diff --git a/file.h b/file.h
 | 
						|
index 1b0cf85..b3843c0 100644
 | 
						|
--- a/file.h
 | 
						|
+++ b/file.h
 | 
						|
@@ -67,28 +67,28 @@ typedef unsigned crc_t;
 | 
						|
 crc_t crc_compute(const char* data, unsigned len);
 | 
						|
 crc_t crc_compute(crc_t pred, const char* data, unsigned len);
 | 
						|
 
 | 
						|
-bool file_exists(const std::string& file) throw (error);
 | 
						|
-void file_write(const std::string& path, const char* data, unsigned size) throw (error);
 | 
						|
-void file_read(const std::string& path, char* data, unsigned size) throw (error);
 | 
						|
-void file_read(const std::string& path, char* data, unsigned offset, unsigned size) throw (error);
 | 
						|
-time_t file_time(const std::string& path) throw (error);
 | 
						|
-void file_utime(const std::string& path, time_t tod) throw (error);
 | 
						|
-unsigned file_size(const std::string& path) throw (error);
 | 
						|
-crc_t file_crc(const std::string& path) throw (error);
 | 
						|
-void file_copy(const std::string& path1, const std::string& path2) throw (error);
 | 
						|
-void file_move(const std::string& path1, const std::string& path2) throw (error);
 | 
						|
-void file_remove(const std::string& path1) throw (error);
 | 
						|
-void file_mktree(const std::string& path1) throw (error);
 | 
						|
+bool file_exists(const std::string& file) noexcept (false);
 | 
						|
+void file_write(const std::string& path, const char* data, unsigned size) noexcept (false);
 | 
						|
+void file_read(const std::string& path, char* data, unsigned size) noexcept (false);
 | 
						|
+void file_read(const std::string& path, char* data, unsigned offset, unsigned size) noexcept (false);
 | 
						|
+time_t file_time(const std::string& path) noexcept (false);
 | 
						|
+void file_utime(const std::string& path, time_t tod) noexcept (false);
 | 
						|
+unsigned file_size(const std::string& path) noexcept (false);
 | 
						|
+crc_t file_crc(const std::string& path) noexcept (false);
 | 
						|
+void file_copy(const std::string& path1, const std::string& path2) noexcept (false);
 | 
						|
+void file_move(const std::string& path1, const std::string& path2) noexcept (false);
 | 
						|
+void file_remove(const std::string& path1) noexcept (false);
 | 
						|
+void file_mktree(const std::string& path1) noexcept (false);
 | 
						|
 
 | 
						|
-std::string file_temp(const std::string& path) throw ();
 | 
						|
-std::string file_randomize(const std::string& path, int n) throw ();
 | 
						|
-std::string file_name(const std::string& file) throw ();
 | 
						|
-std::string file_dir(const std::string& file) throw ();
 | 
						|
-std::string file_basename(const std::string& file) throw ();
 | 
						|
-std::string file_basepath(const std::string& file) throw ();
 | 
						|
-std::string file_ext(const std::string& file) throw ();
 | 
						|
-int file_compare(const std::string& path1, const std::string& path2) throw ();
 | 
						|
-std::string file_adjust(const std::string& path) throw ();
 | 
						|
+std::string file_temp(const std::string& path) noexcept (true);
 | 
						|
+std::string file_randomize(const std::string& path, int n) noexcept (true);
 | 
						|
+std::string file_name(const std::string& file) noexcept (true);
 | 
						|
+std::string file_dir(const std::string& file) noexcept (true);
 | 
						|
+std::string file_basename(const std::string& file) noexcept (true);
 | 
						|
+std::string file_basepath(const std::string& file) noexcept (true);
 | 
						|
+std::string file_ext(const std::string& file) noexcept (true);
 | 
						|
+int file_compare(const std::string& path1, const std::string& path2) noexcept (true);
 | 
						|
+std::string file_adjust(const std::string& path) noexcept (true);
 | 
						|
 
 | 
						|
 #endif
 | 
						|
 
 |