POSIX到DOS和DOS在C POSIX路径转换 [英] POSIX to DOS and DOS to POSIX path conversion in C

查看:204
本文介绍了POSIX到DOS和DOS在C POSIX路径转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和Cygwin的GCC,在这里我想用巧舌如簧的 g_get_current_dir 在Windows和以及在Linux中打印当前目录路径播放。问题是,应用程序总是打印路径POSIX格式在Windows中。但我想它在DOS格式打印在Windows和POSIX格式的Linux操作系统。我会怎么做呢?我知道cygpath实用工具,但是这是一个外部工具,我要寻找一个标准库函数或类似的东西要做到这一点,从 C code。

之内

有人能帮帮我吗?

注:我知道这是一个非常基本的问题,但无法找到,所以,只要讲究,所以如果它是一个重复的问题,请点我正确的线程,我会高兴地删除这个

解决方案

您可以做到这一点与 cygwin_conv_path 功能,在的 Cygwin的参考

I was playing with the Cygwin GCC, where I wanted to print the current directory path using glib's g_get_current_dir in Windows and as well as in Linux. The problem is that the app is printing the path always in posix format in windows. But I wanted it to print in dos format in windows and posix format in linux. How would I do that? I know about cygpath utility but that is an external utility, I am looking for a standard library functions or something similar to do that from within C code.

Can someone please help me?

NOTE: I know it's a very basic question, but could not find anything particular about it in SO, so if it is a duplicate question, please point me to the right thread, I'll delete this one happily.

解决方案

You can do that with the cygwin_conv_path function, documented in the Cygwin API Reference.

这篇关于POSIX到DOS和DOS在C POSIX路径转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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