English 中文(简体)
• 如何确定何时更新案卷(++)?
原标题:How to determine when a file is updated in c++?

I am using an application which takes File X as input and gives File Y and Z as output (graphs and plots)
Now if the applicatoin is run again :

  1. File Y and Z already exists and File X is not updated then it should not be over-written.
  2. File X is updated, then File Y and Z must be overwritten.

法典在C++中写成,如何改变法典,从而满足这两种条件? 我是否应当每次拿X的邮票?

问题回答

If you are on a POSIX machine, use stat or a related function such as fstat. The windows equivalents are described at http://msdn.microsoft.com/en-us/library/14h5k7ff(v=vs.80).aspx.

stat归还的结构或窗口对口单位有一个代表文件最后修改时间的领域。

You could just keep a hash of file X. If the has changes, the file has been changed (updated), and you will need to update Y and Z.

if (XHashPrev != XHashNow || !YZExist)
    // update files.

如果X的修改晚于Y或Z,则使用David Hammen的回答,对X的修改时间长度与Y和Z进行比较,因此这些修改已经过时,应当改写。

是的,你应检查第十卷,看看(两种选择):

  • if its update date changed or
  • or if its content changed (using a CRC32 as an example).

首先是最容易和最快的。 第二是最准确的。 <>><>EDIT further to the comments below: 这两项备选办法可以结合起来,达成妥协。

另一种可能性是:用X书写基本方案,总是超过Y和Z字。 加入基本方案。 一份概述如下的文件:

Y Z : X
    basicProgram X Y Z

should do the trick. You can then invoke it with either "make Y" or "make Z" Bottom line: let make worry about timestamps and such.





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签