what is the meaning of stable in zfile_stable - CZMQ - c

CZMQ man page for zfile explains zfile_stable as:
// Check if file is 'stable'
CZMQ_EXPORT bool zfile_stable (const char *filename);
What is the meaning of stable? when a file is said to be stable?

The use case here is using files to signal between processes. The example application is FileMQ, which publishes new files out to subscribers. But there's no obvious way to know when a file has been "created"; the two solutions I know are to create a second "signal" file, which is rather clumsy, or to use this "has the file been modified in the last second" algorithm.
Let's say you're copying photos into one directory, and a parallel process is detecting new photos and uploading them to a server. On a large photo, the modified date will keep changing until it's stable. Then, it's safe to upload the photo.
Hope that helps.

The definition of stable in this context is if a file more than 1s old.
See https://github.com/zeromq/czmq/blob/master/src/zfile.c#L115

Related

How to call one object file from another using c

I've been writing some simple console application in c and on linux and came across a problem. I need to run one object file from another.
When i want to open a text or binary file i would do something like this:
FILE* fp = fopen(path, mode);
and then just write to that file or read from it. But when it comes to object files i don't even know what to start with.
Globally, the situation is that there is a compiled object file which functionality needs to be tested (lets call it "target"). The test is driven by another compiled object file (let's call it "tester"). So, when i run the "tester" it queries for path to "target". When path is acquired, "tester" tests "target".
So, what i ask here is what this whole situation (coding of object files interaction) is called so i could go and rtfm? I lurked a bit and found some concepts like unit testing and APIs but brief view didn't give me strong impression that those things are what i'm looking for.
Thank you!

How can I tell if I have permissions to delete a file with Qt5 without actually trying to delete it?

Question
I am looking for something that would fulfil the expected semantics of an imagined isRemovable() method in the QFile class.
In QFile reference there is a permissions() method mentioned that returns a set of flags QFileDevice::Permission wich basically corresponds to file permissions. There is also isReadable() and isWritable() but how can I in a relatively portable way know with certainty that I would be able to remove (delete) a file without actually trying?
Answer
Short answers with short and simple source-code are preferred.
You can remove a file if you have permissions to write both to a file and to it's containing directory. So, the solution (which I've tested on Centos Linux) will be:
QFileInfo fileInfo(filepath);
QFileInfo dirInfo(fileInfo.path());
bool isRemovable = fileInfo.isWritable() && dirInfo.isWritable();

Difference between file .crypt and .crypt5

What is the difference between the files with an extension .crypt versus file with and extension .crypt5?
.crypt5 is the newest version of What's App database files, actually they are using .crypt7 now (29/04/2014)
There are ways to convert .crypt5 to crypt but I'm still researching. I'll get back to the thread once I'm done.

I have a .c.save file. What is it? What does it do?

I am programming with C using Code::Blocks. My project is divided in 3, header, implementation and main.
Whenever I used a project, apart from the source files and the bin and obj folders I had a .depend and a .layout file. All good.
Now I created a new project, and just copied -> pasted everything new in source files. I did this twice.
For each case, I have a .c.save file, which has the same name of the implementation file (ie. the implementation file is called imp, then the file is called imp.c.save). I asked a friend of mine what it might be, and he said I need to beware as he had two random files created, which prevented him from building correctly (he got a stupid error). When the files were deleted everything went back to normal.
I did a short test of the program and I can find nothing different. I am hesitant to delete it since this cropped up twice in two cases, but I don't want to compromise my coding.
Tried to google and I didn't find much. Any help?
Well, it didn't cause any problems so I assuming it is an autosave file.

make file running on Linux - how to ignore case sensitive?

I have a huge project, whole written in C language and I have a single make file that is used to compile it. The project C files contains lots of capitalize problems in it's header files, meaning there are tones of header files that were miss-spelled in lots of C files.
The problem is I need to migrate this project to compile on Linux machine and since Linux is case sensitive I got tones of errors.
Is there an elegant way which I can run make file in Linux and tell him to ignore case sensitive?
Any other solution will be welcome as well.
Thanks a lot.
Motti.
You'll have to fix everything by hand and rename every file or fix every place with #include. Even if you have a huge project (comparable with linux kernel), it should be possible to do this during a hour or two. Automation may be possible, but manual way should be better - because script won't be able to guess which name is right - filename, or the name used in #include.
Besides, this situation is a fault of original project developer. If he/she wasn't sloppy and named every header in every #include correctly, this wouldn't happen. Technically, this is a code problem similar to syntax error. The only right way to deal with it is to fix it.
I think it takes not too long to write a small script, which goes thru the directories first, then replaces C headers. Explained:
Scan the headers' folder and collect filenames.
Make a lowercase list of them. You have now original and locased pairs.
Scan the C source files and find each line contains "#include"
Lowercase it.
Find the lowercase filename in the list collected and lowercased from headers.
Replace the source line with the one collected from headers.
You should put the modified files into a separate folder structure, avoid overwriting the whole source with some buggy stuff. Don't forget to create target folders during the source tree scan.
I recommend a script language for that task, I prefer PHP, but just it's the only server-side script language which I know. Yep, it will run for a while, but only once.
(I bet that you will have other difficulties with that project, this problem is not a typical indicator of high quality work.)
Well I can only tell you that you need to change the case of those header files. I don't know that there is any way you can make it automatic but still you can use cscope to do it in a easier way.
http://www.linux-tutorial.info/modules.php?name=ManPage&sec=1&manpage=cscope
You can mount the files on a case-insensitive file system. FAT comes to mind. ntfs-3g does not appear to support this.
I use the find all and replace all functionality of Source Insight when i have to do complete replacement. But your problem seems quite big, but you can try the option to replace every header file name in all occurences of source files using the
"Find All" + "Replace" functionality. You can use notepad++ too for doing the same.
A long time ago there was a great tool under MPW (Macintosh Programmer's Workshop) called Canon. It was used to canonize text files, i.e. make all symbols found in a given refernce list have have the same usage of upper/lower case. This tool would be ideal for a task like this - I wonder if anything similar exists under Linux ?

Resources