问:便携式方式使用C在Unix上使用C复制文件 - 直接或类似 [英] Q: portable way copy files using C on Unix an Windows -- dirent or similar

查看:69
本文介绍了问:便携式方式使用C在Unix上使用C复制文件 - 直接或类似的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要哪些文件#included才能将文件复制到新的
目录并且可以移植?

ie。在Unix(SGI和Linux)或Windows 2000中使用它。

#ifdefs确定。


在SGI上使用dirent.h,但它不是在Windows上使用VS6.0。


谢谢。

解决方案

** - > Guy Downstairs< - **写道:

需要哪些文件#included才能将文件复制到新的
目录并可移植?
ie 。在Unix(SGI和Linux)或Windows 2000中使用它。
#ifdefs确定。

在SGI上使用dirent.h,但它不适用于Windows w / VS6.0 。

谢谢。



没有标准的方法可以做到这一点。您可能可以使用

gtk +或类似的东西在C中(或QT / wxWidgets

for C ++)。

标准C甚至不知道目录是什么。


-

Ioan - Ciprian Tandau

tandau _at_ freeshell _dot_组织(希望它还为时不晚)

(......它仍然有效......)


** - - >那个Guy Downstairs< - **写道:

< snip>

在SGI上使用dirent.h,但它不适用于Windows w / VS6 .0。




这是POSIX。它不应该在Windows上运行。但是,

您可以使用mingw或

cygwin在Windows上编译源代码,它会起作用。我不确定这些依赖性如何在这些下工作。


-

Ioan - Ciprian Tandau

tandau _at_ freeshell _dot_ org(希望现在还不算太晚)

(......它还能运作......)


** - > Guy Downstairs< - **写道:

需要哪些文件#included才能将文件复制到新的
目录并可移植?
ie 。在Unix(SGI和Linux)或Windows 2000中使用它。
#ifdefs确定。

在SGI上使用dirent.h,但它不适用于Windows w / VS6.0 。




C标准对目录一无所知,所以你不能在

标准C中这样做,这是这个主题小组。


我建议你为POSIX编写POSIX例程系统

(包括Linux)和Windows的Windows例程,然后设置你的

构建系统,以便在每个系统上构建相应的例程。

从代码的其余部分隔离所有这些例程,然后至少

大部分代码都是常见且便携的。


特定例程的详细信息以及如何配置构建

环境,这里不在此处。

-

Flash Gordon

生活在有趣的时代。

虽然我的电子邮件地址说垃圾邮件,但它是真实的,我读了它。

What files are needed to be #included to be able to copy files to a new
directory and be portable?
ie. use it in Unix (SGI and Linux) or Windows 2000.
#ifdefs Ok.

using dirent.h on SGI, but it''s not working on Windows w/ VS6.0.

Thanks.

解决方案

**--> That Guy Downstairs <--** wrote:

What files are needed to be #included to be able to copy files to a new
directory and be portable?
ie. use it in Unix (SGI and Linux) or Windows 2000.
#ifdefs Ok.

using dirent.h on SGI, but it''s not working on Windows w/ VS6.0.

Thanks.


There''s no standard way to do that. You may be able to use
gtk+ or something similar to do that in C (or QT/wxWidgets
for C++).
The standard C has no idea of what a directory is, even.

--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it''s not too late)
(... and that it still works...)


**--> That Guy Downstairs <--** wrote:
<snip>

using dirent.h on SGI, but it''s not working on Windows w/ VS6.0.



This is POSIX. It''s not supposed to work on Windows. However,
you can compile the sources on Windows using mingw or
cygwin and it will work. I''m not sure how the dependency
works under those, though.

--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it''s not too late)
(... and that it still works...)


**--> That Guy Downstairs <--** wrote:

What files are needed to be #included to be able to copy files to a new
directory and be portable?
ie. use it in Unix (SGI and Linux) or Windows 2000.
#ifdefs Ok.

using dirent.h on SGI, but it''s not working on Windows w/ VS6.0.



The C standard knows nothing about directories, so you can''t do this in
standard C which is the topic of this group.

I would recommend you write a POSIX routine for the POSIX like systems
(including Linux) and a Windows routine for Windows, then set up your
build systems so that the appropriate routine is built on each system.
Isolate all such routines from the rest of your code, then at least the
bulk of your code is common and portable.

The details of the specific routines, and how to configure your build
environments, are off topic here.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.


这篇关于问:便携式方式使用C在Unix上使用C复制文件 - 直接或类似的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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