mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-30 23:52:43 +00:00 
			
		
		
		
	 5e1499d104
			
		
	
	
		5e1499d104
		
	
	
	
	
		
			
			This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).
This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
		
	
			
		
			
				
	
	
		
			44 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2022, the SerenityOS developers.
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <LibCore/DirIterator.h>
 | |
| #include <fcntl.h>
 | |
| #include <sys/stat.h>
 | |
| #include <sys/time.h>
 | |
| 
 | |
| namespace Test {
 | |
| 
 | |
| inline double get_time_in_ms()
 | |
| {
 | |
|     struct timeval tv1;
 | |
|     auto return_code = gettimeofday(&tv1, nullptr);
 | |
|     VERIFY(return_code >= 0);
 | |
|     return static_cast<double>(tv1.tv_sec) * 1000.0 + static_cast<double>(tv1.tv_usec) / 1000.0;
 | |
| }
 | |
| 
 | |
| template<typename Callback>
 | |
| inline void iterate_directory_recursively(ByteString const& directory_path, Callback callback)
 | |
| {
 | |
|     Core::DirIterator directory_iterator(directory_path, Core::DirIterator::Flags::SkipDots);
 | |
| 
 | |
|     while (directory_iterator.has_next()) {
 | |
|         auto name = directory_iterator.next_path();
 | |
|         struct stat st = {};
 | |
|         if (fstatat(directory_iterator.fd(), name.characters(), &st, AT_SYMLINK_NOFOLLOW) < 0)
 | |
|             continue;
 | |
|         bool is_directory = S_ISDIR(st.st_mode);
 | |
|         auto full_path = ByteString::formatted("{}/{}", directory_path, name);
 | |
|         if (is_directory && name != "/Fixtures"sv) {
 | |
|             iterate_directory_recursively(full_path, callback);
 | |
|         } else if (!is_directory) {
 | |
|             callback(full_path);
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 | |
| }
 |