cost 259 ms
使用 C++ 检查文件是否在当前目录或其子目录中 - Check if a file is in the current directory or its children using C++

作为爱好项目的一部分,我正在 C++ 中编写一个小型 HTTP web 服务器,我需要提供 static 个文件。 但是,我想避免的一个问题是用户输入,例如http://example.com/../passwd 。 为了确保用户不会输入恶意路径,我想检查输入的路径是否在当前父目录中。 我目前的方法 ...

std::filesystem::recursive_directory_iterator 和读取权限 - std::filesystem::recursive_directory_iterator and read permision

在 Linux 下: 我正在尝试使用“recursive_directory_iterator”访问文件夹,但它抛出了“权限被拒绝”异常。 以下是给定文件夹的权限: 这意味着“其他人”有 exec,因此应该能够查看和输入“my_subfolder”。 为什么迭代器会抛出异常,因为仍然允许查看? 我怎 ...

std::unordered_set<std::filesystem::path> :在 v.12 以下的 clang 和 g++ 上编译错误。 错误或用户错误?</std::filesystem::path> - std::unordered_set<std::filesystem::path>: compile error on clang and g++ below v.12. Bug or user error?

我在我的项目中添加了以下 function 模板,用户抱怨它不再在他们的系统上编译:template&lt;typename T&gt; std::size_t removeDuplicates(std::vector&lt;T&gt;&amp; vec) { std::unordered ...

recursive_directory_iterator 期间的 std::system::error 异常 | Unicode C++ 中的翻译异常 1113 - std::system::error exception during recursive_directory_iterator | Unicode Translation Exception 1113 in C++

当我偶然发现这个看似未知/无法修复的错误时,我正在使用std::filesystem的recursive_directory_iterator进行一个更大的项目。 我将项目简化到最低限度以重新创建错误。 另一个提问者找到了提供skip_permission_denied选项的解决方案,这对我没有任 ...

c++ 17 std::filesystem 不能在其他(windows 10)计算机上运行 - c++ 17 std::filesystem can not run on other (windows 10) computer

我有一个程序,在 Windows 10 上使用 MinGW 编译,我希望这个程序在其他人的计算机上运行,​​即使他们没有安装 MinGW 或任何 c++ 编译器。 通常,这很容易。 我只包含任何第三方库的 exe 文件和 dll 文件,它确实有效……除非我使用一个特定的 c++ 标准库,即 c+ ...

在 Qt 应用程序中传递文件路径的推荐方式 - Recommended way of passing file paths in Qt application

在我正在处理的代码库(C++ 和 Qt5)中,文件路径大部分时间都作为 QString 参数传递。 在某些情况下,它也是 QDir 和 QString 的组合。 例子: 为了对接口使用更强的类型,我正在考虑以下类型: 字符串 目录 文件 QFileInfo 网址 标准::文 ...

不存在文件的 std::filesystem::equivalent 版本 - Version of std::filesystem::equivalent for non-existing files

我的程序应该使用用户指定的路径创建两个文件。 在我开始更改文件系统之前,我需要知道路径是否指向相同的位置,以错误结束。 因为路径来自用户,所以它们应该是非规范的和奇怪的。 例如,它们可以是./dir1/subdir/file和dir2/subdir/../subdir/file ,其中dir2是指 ...

std::filesystem::copy 将文件复制到另一个预先存在的目录时出错 - Error with std::filesystem::copy copying a file to another pre-existing directory

请参阅下面的代码,然后是下面的错误。 尝试使用 filesystem::copy 以及尝试不同的路径。 没有任何运气。 由于上面列出的问题,我不能在这里写太多,可能是一个简单的格式问题。 话虽这么说,它在我的家用计算机上使用 visual studio 2022 工作,但是使用 VS Code 和 ...

如何正确处理带有 std::filesystem::path 的长路径前缀的 windows 路径 - How to properly handle windows paths with the long path prefix with std::filesystem::path

std::filesystem::path似乎没有意识到windows long path magic prefix 。 这是每个设计还是有可以使用的模式/标志/编译器开关/第 3 方库? 铁对于像C:\temp\test.txt这样的路径, root_name是C:和root_path是C:\这 ...

C++ MFC 从编辑框中读取 Cstring 用于文件读取(std::filesystem Exception unhandled memory 问题) - C++ MFC reading Cstring from editbox for file reading (std::filesystem Exception unhandled memory problem)

我的代码要实现的是在给定文件路径输入和 output 后读取文件名(开关1:同一文件夹下的文件)(开关2:目录下的所有文件名,包括子目录),并且不将文件夹名称存储到向量中(1.png 2.png 3.png 但不是 ChildFolder)。 如果您需要有关文件夹结构的额外信息,请参阅我之前的问题 ...

recursive_directory_iterator 的 skip_permission_denied 选项似乎在 macOS 上被忽略? - recursive_directory_iterator's skip_permission_denied option appears to be ignored on macOS?

在 macOS 上使用 C++20 和std::filesystem::recursive_directory_iterator ,此代码: 根据我对文档的理解,应该跳过它无权递归到的目录,在尝试递归到~/Library/Application Support/MobileSync/时遇到错误。 ...

您将使用哪种类型在 C++ 库 API 中传递文件路径? - What type would you use for passing file paths in your C++ library API?

自从我开始使用 C++17 以来,每次我必须开发一个新库时,我都会考虑几种将文件路径传递给公共函数/方法的替代方案。 这些是我通常对这个话题的一些想法: 通过在公共函数中使用std::filesystem::path ,我将向 C++17 添加强依赖。 我的图书馆的消费者需要有一个 C++17 编 ...

遍历 C++ 中的所有目录和子目录 - iterating through all the directories and subdirectories in c++

我想使用std::filesystem::recursive_directory_iterator类来创建一个类方法,它遍历所有子目录并处理找到的 xml 文件。 我在互联网上找到的唯一方法是使用这样的 for 循环: 问题是我需要在函数调用之间存储我的迭代器(或至少它指向的位置),因为我一次 ...


 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM