Sujet : Re: saving fileXXX.bmp
De : malcolm.arthur.mclean (at) *nospam* gmail.com (Malcolm McLean)
Groupes : comp.lang.cDate : 24. Mar 2024, 18:34:25
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <utpo73$g827$1@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
On 24/03/2024 16:44, fir wrote:
i want to save bitmap (when using editor) but i dont wannt
to pen a dialog for saving ui just wana do quicksave but not replace
the file already exist so i want to maybe use such scheme i will sawe
"painting001.bmp" and if there is such number i will just increase
the number to 002 if such exist i will use 003 and so on
do yu thing it is standable to use c std lib (and probably just
fopen fclose to detect if that file already exist of there is a need
to use some specific windows functions?
i never used it though - though maybe i could becouse code
that is able to walk on directories and read all files may be handy
for various practical usage (liek finding something , removing duplicates etc)
That should work. Tty to open painting001,bmp for reading. If the function succeeds, then obviously the file exists, so try painting002.bmp, painting300 and so on, until eventually you must find one whuch fails. Either the file doesn't exist, or there is something funny with it. So try to open painting500.bmp for writing. If it fails, then unless you are out of disk space, there probably was a painting500,bmp file with someting funny with it, so increement again. If it works, then write file.
It should be pretty robust, except that Microsoft have been breaking standard library calls like fopen.
To write the bmp file itself with just fopen, raid
https://github.com/MalcolmMcLean/babyxrcand take bmp.c, bmp.h. Check the docs at.
http://malcolmmclean.github.io/babyxrc/sourcefiles.html-- Check out Basic Algorithms and my other books:https://www.lulu.com/spotlight/bgy1mm