为获得更好的iostream的错误信息 [英] Getting better error messages for iostreams

查看:125
本文介绍了为获得更好的iostream的错误信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现了一个小程序,可以提取(并通过保险丝贴装)有一定的压缩格式。我使用的boost ::文件系统:: ifstream的,但在错误(例如,用户要提取不存在的文件),我变得非常不起眼的错误消息。我不知道是否有一种方式来获得在C ++?

I implemented a small program that can extract (and via fuse mount) a certain archive format. I use boost::filesystem::ifstream, but on error (e.g. the file a user wants to extract does not exist) I get very nondescript error messages. I wonder is there a way to get better error messages for IO related problems in C++?

在一个相关的说明我不知道我是否应该用C'S FILE * 或保险丝文件系统只是简单的文件描述符的情况下?因为字符串错误(错误)是比什么iostream是给了我更好的。

On a related note I wonder whether I should have used C's FILE* or in the case of the fuse filesystem just plain file descriptors? Because strerror(errno) is way better than what iostreams are giving me.

推荐答案

我们无法找到比使用boost :: iostream和实现我们自己的基于文件的接收器和源没有更好的方法。

We couldn't find any better way than using boost::iostreams and implementing our own file-based sink and source.

如果你愿意,你可以在这里抓源头code(Apache许可的):

If you want, you can grab the source code here (Apache-licensed):

http://sourceforge.net/projects/cgatools/files/1.3.0/cgatools-1.3.0.9-source.tar.gz/download

相关文件是:

cgatools / UTIL /流。[CH]页

cgatools/util/Streams.[ch]pp

这篇关于为获得更好的iostream的错误信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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