問題タブ [boost-filesystem]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c++ - boost::copy_file copy_option で既存の宛先ファイルをスキップしますか?
ファイルを別のファイルにコピーしたいのですが、Boost::copy_file を使用したいと思います。次のような copy_option というパラメーターがあります。
ここで動作に関する別の質問を見つけましoverwrite_if_exists
た: how to perform boost::filesystem copy_file with overwrite
fail_if_exists = none
ただし、私の問題は、オプションの使用方法がわからないことです。対象のファイルが既に存在する場合、コピー操作をスキップしたいと考えています。
私はそれが可能であることを知っていますがif ( !exists(path) )
、どのように機能するかを理解したいですcopy_option
。
fail_if_exists = none
Boost::copy_file 関数内でどのように使用できますか?
更新: コードを修正しました。boost doc Web サイトのコードは壊れています。
c++ - おそらく新しいディレクトリにファイルを保存する方法は?
したがってboost::filesystem::path Base
、フォルダーが存在しない場合はフォルダーを作成し、文字列からバイナリファイルを作成するベースがあります。現在、私は次のような機能を持っています:
ディレクトリから存在する必要があります。では、目的の機能を実現するために、関数を boost.filesystem API に更新する方法を知りたいですか?
c++ - ディレクトリ内の新しいファイルを確認するにはどうすればよいですか?
与えられた:
filesystem::path toDir("./");
ptime oldTime;
ptime now(second_clock::local_time());
oldTime
との間の期間に作成されたファイルを特定するにはどうすればよいnow
ですか?
このような「新しい」ファイルの名前は、にストリーミングする必要がありますcout
。
更新: 与えられた答えに基づいて、私は小さなプログラムを作成しました:
しかし、それは新しいファイルを表示しないようです=(それを修正する方法は?
アップデート2:
で解決nowTime = second_clock::universal_time();
アップデート3: 修正されたコード:
sync - boost::filesystem::create_directories() によって作成されたディレクトリにすぐにアクセスできませんか?
boost::filesystem::create_directories()
新しいディレクトリを作成するために使用しています。作成直後にこれらのディレクトリにアクセスしようとすると、「そのようなディレクトリはありません」というエラーが表示されます。しかし、ディレクトリを作成した後にしばらくスリープすると、すべて問題ありません (エラーは発生しません)。また、ディレクトリを作成した後にfsync()
andを使用してみましたが、違いはありませんでした。sync()
ext4 および xfs ファイル システムでテストしており、ブースト バージョンはブースト 1.44 です。
私の質問は
boost::create_directories()
ディレクトリを即座に作成しますか? それとも何かが間違っている可能性はありますか?- また、ext4/xfs ですべてをディスクにフラッシュすることが
sync()
保証fsync()
されていますか?
windows - Why does boost::filesystem is_directory return different results when run as a Windows Service?
I have some code that iterates through files in a directory and does useful things with the non-directory files, like so:
This works fine in my unit tests, but when I run the full program as a service, my test directories (seemingly erroneously) get past the !bfs::is_directory
check and DoUsefulThings
's ifstream.good()
check fails, with an errno of 13.
I tried changing !bfs::is_directory
to bfs::is_regular_file
(thinking that maybe there was a system condition causing it to be something else), but I got the same results. The is_regular_file
condition fails on the directory in my unit test but passes when run as a service.
I also added a try/catch around my if statement to see if it was throwing an exception and verified that it wasn't (probably could use one anyway, but didn't help with this).
I considered that the problem could be related to the service's permissions level, so I changed the properties of the service to log on as the same account that I use to log in to that system. Same result. I've dabbled with PerformanceMonitor some as well to try to get some clues there, but I haven't gleaned much from it yet.
Can someone suggest why this might be happening? Errno=13 == "permission denied", right? Is there an additional check I need to perform before calling is_directory?
I'm using Windows XP, Visual Studio 2008/C++, version 1.44 of the Boost library, and version 3 of filesystem.
ETA: I added the following to test the directory manually (the direction of the slash marks didn't make a difference), and is_regular_file behaves as expected:
I have log statements printing out both *iterDir and iterDir->path() and they both match the one I put in manually. Does this rule out permissions issues? Will continue testing, as this result doesn't really make sense to me yet.
c++ - boost :: filesystem :: path :: append(イテレータ経由)はコンパイラエラーを引き起こします
次のように使用して新しいパスを生成しようとしてboost::filesystem
います
次のようにコンパイラエラーが発生します
コードの何が問題になっていて、どうすれば修正できますか。前もって感謝します。
c++ - C ++:Boostファイルシステムcopy_fileのエラー
copy_file関数で問題が発生しています。私のプログラムは非常に単純で、テキストファイルをある場所から別の場所にコピーしようとしています。
次のコードは「デバッグエラー」を引き起こします!abort()が呼び出されたためです。
Stackoverflowで他のコードの例を見ると、何が間違っているのかわかりません。ここで明らかな何かが欠けているような気がします。
Boost v1.47をインストールしていて、Visual C++2010を使用しています。
c++ - Boost.Filesystemを使用してプラットフォームのパス区切り文字を取得します
Boost.Filesystemを使用してプラットフォームのパス区切り文字を取得する方法はありますか?/
パス区切り文字とは、Unixと\
Windowsを意味します。
boost::filesystem::path::operator/
2つのパスを適切な区切り文字で連結するために使用できることはすでに知っています。しかし、私はどちらかまたはが欲しいだけ/
です\
。
を使用できることも知っていますが#ifdef _WIN32
、Boost.Filesystemが適切な区切り文字を教えてくれることを望んでいます。
編集: Boost1.48で使用されているBoost.FilesystemAPIのバージョン3を使用したいと思います。
c++ - ブーストファイルシステム::パスコンストラクタstd::length_error
Boost.Filesystemライブラリを使用してディレクトリを反復処理しようとしています。
問題は、パスオブジェクトをインスタンス化しようとすると、「pippo」などの任意の長さの文字列で「stringotolong」というメッセージが表示されたstd::length_errorが発生することです。
私はすでにこれらすべてを試しました:
私は、vc++10用のブーストプリコンパイル済みバージョン1.47を搭載したWindows7を使用しています。
よろしくお願いします、ルカ
編集
これは実行されたブーストコードです(path.hpp 129行目)
エラーは(path_traits.hpp行174)からスローされます
スローする関数は「変換」です。デバッガーから私は両方を見ました
と
正しく実行されます
c++ - BOOST_FOREACH を使用して、ディレクトリ内のすべてのファイルを反復処理します
boost::filesystem と BOOST_FOREACH を使用して、ディレクトリ内のすべてのファイルを反復処理できますか? 私は試した
このコードはコンパイルおよび実行されますが、目的の結果が得られません。