处理文件路径跨平台 [英] Handling file paths cross platform

查看:116
本文介绍了处理文件路径跨平台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在处理跨平台的路径的任何C ++ GNU独立类?我的应用程序构建在Windows和LInux上。我们的配置文件引用一个单独目录中的另一个文件。我想能够读取其他配置文件的路径到一个类中,这将工作在Linux或Windows。

Do any C++ GNU standalone classes exist which handle paths cross platform? My applications build on Windows and LInux. Our configuration files refer to another file in a seperate directory. I'd like to be able to read the path for the other configuration file into a class which would work on both Linux or Windows.

哪个类将提供最小的足迹以转换在任一系统上使用的路径?感谢

Which class would offer the smallest footprint to translate paths to use on either system? Thanks

推荐答案

除非使用绝对路径,否则不需要翻译 - Windows会自动将正斜杠转换为反斜线,所以如果你使用带有正斜杠路径分隔符的相对路径,你会是金色的。你应该真的避免绝对路径,如果可能的话。

Unless you're using absolute paths, there's no need to translate at all - Windows automatically converts forward slashes into backslashes, so if you use relative paths with forward slash path separators, you'll be golden. You should really avoid absolute paths if at all possible.

这篇关于处理文件路径跨平台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆