Re: saving fileXXX.bmp

Liste des GroupesRevenir à cl c  
Sujet : Re: saving fileXXX.bmp
De : fir (at) *nospam* grunge.pl (fir)
Groupes : comp.lang.c
Date : 25. Mar 2024, 10:10:51
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <utrbig$30267$3@i2pn2.org>
References : 1 2 3
User-Agent : Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24
jak wrote:
fir ha scritto:
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)
>
the question is if if somoene would work longer and had 1000 bitmaps
in folder if this will not slow down, or still be fast etc...could check
experimentally but even then i wouldnt be sure if this is kinda
optimal or wastefull way
>
In order not to manage too many differences between compilers you could
try this way:
>
#include <stdio.h>
#include <limits.h>
>
int main()
{
     char pref[50] = "bmp_file_",
          cmd[1024],
          str[PATH_MAX];
     int  seq;
     FILE *fp, *f;
>
     sprintf(cmd, "c:\windows\system32\cmd.exe /c dir /b /o:-n %s???
2>nul", pref);
>
     if((fp = popen(cmd, "rt")) != NULL)
     {
         if(fgets(str, PATH_MAX, fp) != NULL)
         {
             sscanf(str, "%[^0-9]%3d%*", pref, &seq);
             sprintf(str, "%s%03d", pref, ++seq);
         }
         else
             sprintf(str, "%s%03d", pref, 1);
>
         pclose(fp);
>
         if((f = fopen(str, "r")) == NULL)
         {
             if((f = fopen(str, "w")) == NULL)
                 printf("cannot create %s", str);
         }
         else
             printf("%s already exist", str);
>
         if(f != NULL) fclose(f);
     }
     else
         printf("cannot open process");
>
     return 0;
}
>
This piece of code is only used to give the idea and is not well tested.
that is almost for sure bad - its liek running separate console program
to add two strings or numbers

Date Sujet#  Auteur
24 Mar 24 * saving fileXXX.bmp24fir
24 Mar 24 +* Re: saving fileXXX.bmp2Malcolm McLean
25 Mar 24 i`- Re: saving fileXXX.bmp1Mikko
24 Mar 24 +* Re: saving fileXXX.bmp14fir
24 Mar 24 i+* Re: saving fileXXX.bmp10jak
25 Mar 24 ii`* Re: saving fileXXX.bmp9fir
25 Mar 24 ii `* Re: saving fileXXX.bmp8jak
26 Mar 24 ii  `* Re: saving fileXXX.bmp7fir
26 Mar 24 ii   `* Re: saving fileXXX.bmp6fir
26 Mar 24 ii    `* Re: saving fileXXX.bmp5jak
27 Mar 24 ii     `* Re: saving fileXXX.bmp4fir
27 Mar 24 ii      `* Re: saving fileXXX.bmp3jak
27 Mar 24 ii       `* Re: saving fileXXX.bmp2fir
28 Mar 24 ii        `- Re: saving fileXXX.bmp1jak
25 Mar 24 i`* Re: saving fileXXX.bmp3Malcolm McLean
25 Mar 24 i `* Re: saving fileXXX.bmp2fir
25 Mar 24 i  `- Re: saving fileXXX.bmp1fir
25 Mar 24 `* Re: saving fileXXX.bmp7Mike Terry
25 Mar 24  `* Re: saving fileXXX.bmp6fir
25 Mar 24   `* Re: saving fileXXX.bmp5fir
26 Mar 24    +* Re: saving fileXXX.bmp3fir
26 Mar 24    i`* Re: saving fileXXX.bmp2fir
26 Mar 24    i `- Re: saving fileXXX.bmp1fir
28 Mar 24    `- Re: saving fileXXX.bmp1fir

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal