Changeset 3803
- Timestamp:
- May 12, 2019, 7:35:25 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/utility.cc
r3792 r3803 60 60 void test_fnmatch(test::Suite& suite); 61 61 bool test_fnmatch(bool, std::string, std::string); 62 void test_getcwd(test::Suite& suite); 62 63 void test_remove(test::Suite& suite); 63 64 void test_rename(test::Suite& suite); … … 236 237 test_dirname(suite); 237 238 test_fnmatch(suite); 239 test_getcwd(suite); 238 240 test_remove(suite); 239 241 test_rename(suite); … … 760 762 761 763 764 void test_getcwd(test::Suite& suite) 765 { 766 std::string cwd = utility::getcwd(); 767 suite.out() << "cwd: " << cwd << "\n"; 768 if (cwd.find("/test/testSubDir/") == std::string::npos) { 769 suite.add(false); 770 suite.err() << "error: cwd: expect path to contain 'test/testSubDir/'\n"; 771 } 772 } 773 774 762 775 void test_remove(test::Suite& suite) 763 776 { -
trunk/yat/utility/utility.cc
r3792 r3803 127 127 } 128 128 return false; 129 } 130 131 132 std::string getcwd(void) 133 { 134 char buffer[256]; 135 if (::getcwd(buffer, 256)) 136 return std::string(buffer); 137 if (errno == ERANGE) { 138 char buffer2[4096]; 139 if (::getcwd(buffer2, 4096)) 140 return std::string(buffer2); 141 } 142 throw errno_error("getcwd failed: "); 143 return ""; 129 144 } 130 145 -
trunk/yat/utility/utility.h
r3778 r3803 191 191 bool fnmatch(const std::string& pattern, const std::string& str, 192 192 int flags=0); 193 194 /** 195 \brief current directory 196 197 \see https://linux.die.net/man/3/getcwd 198 199 \since New in yat 0.17 200 */ 201 std::string getcwd(void); 193 202 194 203 /**
Note: See TracChangeset
for help on using the changeset viewer.