• saving fileXXX.bmp

    From fir@21:1/5 to All on Sun Mar 24 17:44:48 2024
    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)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From fir@21:1/5 to fir on Sun Mar 24 22:26:49 2024
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From jak@21:1/5 to All on Sun Mar 24 22:43:39 2024
    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???
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mike Terry@21:1/5 to fir on Mon Mar 25 02:29:33 2024
    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)

    I think the bigger issue is where to create such files? If users have used your app to open some
    existing .bmp file for processing, it's quite possible they won't have write access to that folder.
    In that case a Save or Save As operation should trigger a standard file system file select dialog in
    a GUI program which is fair enough, but it sounds like you want to create a temp file with no user
    intervention? Command line utilities often have some kind of "temp folder" option.

    Ideas to consider:
    - tmpfile() (POSIX?]
    - GetTempFileName(), GetTempPath() [Windows]
    - Use environment variables like TMP/TEMP? (Possibly different usage on different platforms)
    - how to clean up such temp files so they don't pollute the file system long term?
    - ensuring uniqueness? [e.g. if multiple copies of your program are running at the same time]
    (Your idea is ok on this front, provided:
    * only one process can create the temp file and
    * a second open attempt with the same name will fail, and
    * your logic has a loop to recognise such failures and try again with a
    new name etc..
    Note GetTempFileName() fails on this front...)
    - Other filename ideas : including timestamps or GUIDs or PIDs in the filename, but by
    themselves those may not fully solve uniqueness problem.
    - Listing the directory to generate available filenames might be more
    efficient in some usage cases, especially if the API includes file filter options.

    Above aren't really C issues, so there are better places to discuss them.

    Mike.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From fir@21:1/5 to Malcolm McLean on Mon Mar 25 09:09:33 2024
    Malcolm McLean wrote:
    On 24/03/2024 21:26, fir wrote:
    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

    Opening a file is rather a slow operation. But not so slow on most
    platforms. Of course there will come a point where the approach is
    simply too slow. But for saving human-generated bitmaps I don't think
    you'll test the limits.


    but if you open 1000th ypu need to try-open 999 which im not sure is
    okay or not ...im not sure if this opening is like read a directory data
    and localise this name in it or it is more heavy and also involves
    something heavier

    for safety it rather means i should possibly read on api to read
    directory files list better (which probably is also easy as i may just
    google it)

    but i will see yet

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From fir@21:1/5 to Mike Terry on Mon Mar 25 09:07:01 2024
    Mike Terry wrote:
    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)

    I think the bigger issue is where to create such files? If users have
    used your app to open some existing .bmp file for processing, it's quite possible they won't have write access to that folder. In that case a
    Save or Save As operation should trigger a standard file system file
    select dialog in a GUI program which is fair enough, but it sounds like
    you want to create a temp file with no user intervention? Command line utilities often have some kind of "temp folder" option.

    Ideas to consider:
    - tmpfile() (POSIX?]
    - GetTempFileName(), GetTempPath() [Windows]
    - Use environment variables like TMP/TEMP? (Possibly different usage
    on different platforms)
    - how to clean up such temp files so they don't pollute the file system
    long term?
    - ensuring uniqueness? [e.g. if multiple copies of your program are
    running at the same time]
    (Your idea is ok on this front, provided:
    * only one process can create the temp file and
    * a second open attempt with the same name will fail, and
    * your logic has a loop to recognise such failures and try again
    with a
    new name etc..
    Note GetTempFileName() fails on this front...)
    - Other filename ideas : including timestamps or GUIDs or PIDs in the filename, but by
    themselves those may not fully solve uniqueness problem.
    - Listing the directory to generate available filenames might be more
    efficient in some usage cases, especially if the API includes file
    filter options.


    the issue is that standard windows ways to do it - like chose tool form
    menu then use it, save file bny opening save dialogs - are terribly slow
    if someone want to do things wuick and fast - thats why i like the
    programs like irfanview or total commander for example

    here i just want to save current edited image state like by pressing F5
    like quicksave in doom game or something and load it by pressing say F8
    or something

    i would like to save in app directory which probably the application has
    right to write...its editor for my use mainly if not exclusively

    i want to do a lot of things by keystrokes keyholds and mouse not
    by menu etc ..i know such programs are hard to learn and this the
    scope of people using them gets down but in turn are quick to do things
    if you learn them

    hovever i dropped the idea to rapidly code this (becouse other
    occupations) but the problem of saving this is somewhat worth to learn

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From fir@21:1/5 to jak on Mon Mar 25 09:10:51 2024
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From fir@21:1/5 to fir on Mon Mar 25 09:24:38 2024
    fir wrote:
    Malcolm McLean wrote:
    On 24/03/2024 21:26, fir wrote:
    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

    Opening a file is rather a slow operation. But not so slow on most
    platforms. Of course there will come a point where the approach is
    simply too slow. But for saving human-generated bitmaps I don't think
    you'll test the limits.


    but if you open 1000th ypu need to try-open 999 which im not sure is
    okay or not ...im not sure if this opening is like read a directory data
    and localise this name in it or it is more heavy and also involves something heavier

    for safety it rather means i should possibly read on api to read
    directory files list better (which probably is also easy as i may just
    google it)

    but i will see yet


    i found the article https://learn.microsoft.com/en-us/windows/win32/fileio/listing-the-files-in-a-directory

    if skipping the microsoft 'jargon' (which i also destaste as many)

    it seems that i may use

    WIN32_FIND_DATA ffd; //for file info i guess

    typedef struct _WIN32_FIND_DATAA {
    DWORD dwFileAttributes;
    FILETIME ftCreationTime;
    FILETIME ftLastAccessTime;
    FILETIME ftLastWriteTime;
    DWORD nFileSizeHigh;
    DWORD nFileSizeLow;
    DWORD dwReserved0;
    DWORD dwReserved1;
    CHAR cFileName[MAX_PATH];
    CHAR cAlternateFileName[14];
    DWORD dwFileType; // Obsolete. Do not use.
    DWORD dwCreatorType; // Obsolete. Do not use
    WORD wFinderFlags; // Obsolete. Do not use
    } WIN32_FIND_DATAA, *PWIN32_FIND_DATAA, *LPWIN32_FIND_DATAA;


    then hFind = FindFirstFile(szDir, &ffd);

    and

    do
    {
    if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
    {
    }
    else
    {
    }
    } while (FindNextFile(hFind, &ffd) != 0);

    at least ms uses pascal function names as i do the rest of the jargon is
    not my - i could think is using all bigcase for kinda enims/consts is acceptable but i probbaly will stay in a way i do it it is variables
    i write lowcase

    they use 64 bit ints format and i so rarely use it i forgot which is
    best for me though possibly i use LARGE_INTEGER (also ms one)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mike Terry@21:1/5 to fir on Mon Mar 25 17:04:22 2024
    On 25/03/2024 08:07, fir wrote:
    Mike Terry wrote:
    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)

    I think the bigger issue is where to create such files?  If users have
    used your app to open some existing .bmp file for processing, it's quite
    possible they won't have write access to that folder. In that case a
    Save or Save As operation should trigger a standard file system file
    select dialog in a GUI program which is fair enough, but it sounds like
    you want to create a temp file with no user intervention?  Command line
    utilities often have some kind of "temp folder" option.

    Ideas to consider:
    -  tmpfile()  (POSIX?]
    -  GetTempFileName(), GetTempPath() [Windows]
    -  Use environment variables like TMP/TEMP?  (Possibly different usage
    on different platforms)
    -  how to clean up such temp files so they don't pollute the file system
    long term?
    -  ensuring uniqueness?  [e.g. if multiple copies of your program are
    running at the same time]
        (Your idea is ok on this front, provided:
        *  only one process can create the temp file and
        *  a second open attempt with the same name will fail, and
        *  your logic has a loop to recognise such failures and try again
    with a
           new name etc..
        Note GetTempFileName() fails on this front...)
    -  Other filename ideas : including timestamps or GUIDs or PIDs in the
    filename, but by
        themselves those may not fully solve uniqueness problem.
    -  Listing the directory to generate available filenames might be more
        efficient in some usage cases, especially if the API includes file
    filter options.


    the issue is that standard windows ways to do it - like chose tool form menu then use it, save file
    bny opening save dialogs - are terribly slow if someone want to do things wuick and fast - thats why
    i like the
    programs like irfanview or total commander for example

    What you're describing is the standard windows way /for the user to identify a file/ e.g. an
    application document that the user has created and wants to save /somewhere they specify/.

    It's not the the standard windows way to create a temporary file for application use. For that
    purpose I imagine the "standard" process would be to call GetTempPath() then possibly create a
    subfolder for your application, and save the file there. "Standard" apps like Visual Studio, Office
    etc. all create temp files without prompting the user with a dialog box.

    Mike.



    here i just want to save current edited image state like by pressing F5
    like quicksave in doom game or something and load it by pressing say F8
    or something

    i would like to save in app directory which probably the application has right to write...its editor
    for my use mainly if not exclusively

    i want to do a lot of things by keystrokes keyholds and mouse not
    by menu etc ..i know such programs are hard to learn and this the
    scope of people using them gets down but in turn are quick to do things if you learn them

    hovever i dropped the idea to rapidly code this (becouse other occupations) but the problem of
    saving this is somewhat worth to learn




    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mikko@21:1/5 to Malcolm McLean on Mon Mar 25 20:28:35 2024
    On 2024-03-24 17:34:25 +0000, Malcolm McLean said:

    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

    Different operationg systems and file systems have different rules
    about valid file names. For example, "painting001.bmp" might be
    too long or the character '.' might be invalid. You could check
    whether the creation of the file fails and if it does try another
    name.

    --
    Mikko

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From fir@21:1/5 to Mike Terry on Mon Mar 25 19:44:34 2024
    Mike Terry wrote:
    On 25/03/2024 08:07, fir wrote:
    Mike Terry wrote:
    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)

    I think the bigger issue is where to create such files? If users have
    used your app to open some existing .bmp file for processing, it's quite >>> possible they won't have write access to that folder. In that case a
    Save or Save As operation should trigger a standard file system file
    select dialog in a GUI program which is fair enough, but it sounds like
    you want to create a temp file with no user intervention? Command line
    utilities often have some kind of "temp folder" option.

    Ideas to consider:
    - tmpfile() (POSIX?]
    - GetTempFileName(), GetTempPath() [Windows]
    - Use environment variables like TMP/TEMP? (Possibly different usage
    on different platforms)
    - how to clean up such temp files so they don't pollute the file system >>> long term?
    - ensuring uniqueness? [e.g. if multiple copies of your program are
    running at the same time]
    (Your idea is ok on this front, provided:
    * only one process can create the temp file and
    * a second open attempt with the same name will fail, and
    * your logic has a loop to recognise such failures and try again
    with a
    new name etc..
    Note GetTempFileName() fails on this front...)
    - Other filename ideas : including timestamps or GUIDs or PIDs in the
    filename, but by
    themselves those may not fully solve uniqueness problem.
    - Listing the directory to generate available filenames might be more
    efficient in some usage cases, especially if the API includes file
    filter options.


    the issue is that standard windows ways to do it - like chose tool
    form menu then use it, save file bny opening save dialogs - are
    terribly slow if someone want to do things wuick and fast - thats why
    i like the
    programs like irfanview or total commander for example

    What you're describing is the standard windows way /for the user to
    identify a file/ e.g. an application document that the user has created
    and wants to save /somewhere they specify/.

    It's not the the standard windows way to create a temporary file for application use. For that purpose I imagine the "standard" process
    would be to call GetTempPath() then possibly create a subfolder for your application, and save the file there. "Standard" apps like Visual
    Studio, Office etc. all create temp files without prompting the user
    with a dialog box.

    Mike.


    i dont want temp file so i dont fully know what you are talkin about

    i just want a quicksave say you draw image and after say 30 seconds of
    editions you pred F5 for quicksave and you got a history of editions in
    a form of many bitmaps in working directory - then you can delect them
    and delete those not needed with total commander

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From jak@21:1/5 to All on Mon Mar 25 19:27:55 2024
    fir ha scritto:
    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


    I knew you would have given a similar answer but if you agree to open
    thousands of files to find the last of them, then you could accept that solution. It does not only do what you say because the system call is
    looking for the file for patterns and reverses the order of the list.
    All things you should do in your program. In any case, on Windows
    systems there are FindFirst/FindNext functions for this type of
    operations. Below is an example where I replace the system call with a
    function that uses the functions given before. The convenience of the
    system call is that on systems *nix works by simply replacing the call
    with "/usr/bin/ls -1r .......".

    #include <stdio.h>
    #include <limits.h>
    #include <stdbool.h>
    #include <windows.h>

    bool FindLastOf(char [], char *);

    int main()
    {
    char pref[] = "bmp_file_",
    f2find[50],
    str[PATH_MAX];
    int seq;
    FILE *f;

    sprintf(f2find, "%s????", pref);
    if(FindLastOf(f2find, str))
    {
    sscanf(str, "%[^0-9]%4d%*", pref, &seq);
    sprintf(str, "%s%04d", pref, ++seq);
    }
    else
    sprintf(str, "%s%04d", pref, 1);

    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);

    return 0;
    }

    bool FindLastOf(char what[], char *result)
    {
    WIN32_FIND_DATA fdF;
    HANDLE hF= NULL;
    bool ret = false;

    *result = '\0';
    if((hF = FindFirstFile(what, &fdF)) != INVALID_HANDLE_VALUE)
    {
    do
    if(strcmp(fdF.cFileName, result) > 0)
    strcpy(result, fdF.cFileName);
    while(FindNextFile(hF, &fdF));
    ret = true;
    FindClose(hF);
    }
    return ret;
    }

    Not even this piece of code is well tested and is just an example.

    Unfortunately, on the systems where the opendir/readir functions are
    available instead of FindFirst/FindFext, the work will be more difficult because they do not have the receipt for patterns.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to jak on Mon Mar 25 20:25:37 2024
    jak <nospam@please.ty> writes:
    fir ha scritto:
    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


    I knew you would have given a similar answer but if you agree to open >thousands of files to find the last of them, then you could accept that >solution. It does not only do what you say because the system call is
    looking for the file for patterns and reverses the order of the list.
    All things you should do in your program. In any case, on Windows
    systems there are FindFirst/FindNext functions for this type of
    operations. Below is an example where I replace the system call with a >function that uses the functions given before. The convenience of the
    system call is that on systems *nix works by simply replacing the call
    with "/usr/bin/ls -1r .......".

    #include <stdio.h>
    #include <limits.h>
    #include <stdbool.h>
    #include <windows.h>

    bool FindLastOf(char [], char *);

    int main()
    {
    char pref[] = "bmp_file_",
    f2find[50],
    str[PATH_MAX];
    int seq;
    FILE *f;

    sprintf(f2find, "%s????", pref);
    if(FindLastOf(f2find, str))
    {
    sscanf(str, "%[^0-9]%4d%*", pref, &seq);
    sprintf(str, "%s%04d", pref, ++seq);
    }
    else
    sprintf(str, "%s%04d", pref, 1);

    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);

    return 0;
    }

    bool FindLastOf(char what[], char *result)
    {
    WIN32_FIND_DATA fdF;
    HANDLE hF= NULL;
    bool ret = false;

    *result = '\0';
    if((hF = FindFirstFile(what, &fdF)) != INVALID_HANDLE_VALUE)
    {
    do
    if(strcmp(fdF.cFileName, result) > 0)
    strcpy(result, fdF.cFileName);
    while(FindNextFile(hF, &fdF));
    ret = true;
    FindClose(hF);
    }
    return ret;
    }

    Not even this piece of code is well tested and is just an example.

    Unfortunately, on the systems where the opendir/readir functions are >available instead of FindFirst/FindFext, the work will be more difficult >because they do not have the receipt for patterns.


    Fortunately, those systems have wordexp(3) and fnmatch(3).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mike Terry@21:1/5 to fir on Mon Mar 25 21:56:59 2024
    On 25/03/2024 18:44, fir wrote:
    Mike Terry wrote:
    On 25/03/2024 08:07, fir wrote:
    Mike Terry wrote:
    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)

    I think the bigger issue is where to create such files?  If users have >>>> used your app to open some existing .bmp file for processing, it's quite >>>> possible they won't have write access to that folder. In that case a
    Save or Save As operation should trigger a standard file system file
    select dialog in a GUI program which is fair enough, but it sounds like >>>> you want to create a temp file with no user intervention?  Command line >>>> utilities often have some kind of "temp folder" option.

    Ideas to consider:
    -  tmpfile()  (POSIX?]
    -  GetTempFileName(), GetTempPath() [Windows]
    -  Use environment variables like TMP/TEMP?  (Possibly different usage >>>> on different platforms)
    -  how to clean up such temp files so they don't pollute the file system >>>> long term?
    -  ensuring uniqueness?  [e.g. if multiple copies of your program are
    running at the same time]
        (Your idea is ok on this front, provided:
        *  only one process can create the temp file and
        *  a second open attempt with the same name will fail, and
        *  your logic has a loop to recognise such failures and try again
    with a
           new name etc..
        Note GetTempFileName() fails on this front...)
    -  Other filename ideas : including timestamps or GUIDs or PIDs in the >>>> filename, but by
        themselves those may not fully solve uniqueness problem.
    -  Listing the directory to generate available filenames might be more >>>>     efficient in some usage cases, especially if the API includes file >>>> filter options.


    the issue is that standard windows ways to do it - like chose tool
    form menu then use it, save file bny opening save dialogs - are
    terribly slow if someone want to do things wuick and fast - thats why
    i like the
    programs like irfanview or total commander for example

    What you're describing is the standard windows way /for the user to
    identify a file/ e.g. an application document that the user has created
    and wants to save /somewhere they specify/.

    It's not the the standard windows way to create a temporary file for
    application use.  For that purpose I imagine the "standard" process
    would be to call GetTempPath() then possibly create a subfolder for your
    application, and save the file there.  "Standard" apps like Visual
    Studio, Office etc. all create temp files without prompting the user
    with a dialog box.

    Mike.


    i dont want temp file so i dont fully know what you are talkin about

    i just want a quicksave say you draw image and after say 30 seconds of editions you pred F5 for
    quicksave and you got a history of editions in a form of many bitmaps in working directory - then
    you can delect them and delete those not needed with total commander


    Sure... if you know where you want to save the quicksaves and you're confident the user will have
    access to that location, no problem. [My earlier idea of putting the date/time in the filename
    might still be useful, e.g. when you come to delete the files later on with TC.]

    Mike.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From fir@21:1/5 to Mike Terry on Tue Mar 26 09:57:24 2024
    Mike Terry wrote:
    On 25/03/2024 18:44, fir wrote:
    Mike Terry wrote:
    On 25/03/2024 08:07, fir wrote:
    Mike Terry wrote:
    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)

    I think the bigger issue is where to create such files? If users have >>>>> used your app to open some existing .bmp file for processing, it's
    quite
    possible they won't have write access to that folder. In that case a >>>>> Save or Save As operation should trigger a standard file system file >>>>> select dialog in a GUI program which is fair enough, but it sounds
    like
    you want to create a temp file with no user intervention? Command
    line
    utilities often have some kind of "temp folder" option.

    Ideas to consider:
    - tmpfile() (POSIX?]
    - GetTempFileName(), GetTempPath() [Windows]
    - Use environment variables like TMP/TEMP? (Possibly different usage >>>>> on different platforms)
    - how to clean up such temp files so they don't pollute the file
    system
    long term?
    - ensuring uniqueness? [e.g. if multiple copies of your program are >>>>> running at the same time]
    (Your idea is ok on this front, provided:
    * only one process can create the temp file and
    * a second open attempt with the same name will fail, and
    * your logic has a loop to recognise such failures and try again >>>>> with a
    new name etc..
    Note GetTempFileName() fails on this front...)
    - Other filename ideas : including timestamps or GUIDs or PIDs in the >>>>> filename, but by
    themselves those may not fully solve uniqueness problem.
    - Listing the directory to generate available filenames might be more >>>>> efficient in some usage cases, especially if the API includes file >>>>> filter options.


    the issue is that standard windows ways to do it - like chose tool
    form menu then use it, save file bny opening save dialogs - are
    terribly slow if someone want to do things wuick and fast - thats why
    i like the
    programs like irfanview or total commander for example

    What you're describing is the standard windows way /for the user to
    identify a file/ e.g. an application document that the user has created
    and wants to save /somewhere they specify/.

    It's not the the standard windows way to create a temporary file for
    application use. For that purpose I imagine the "standard" process
    would be to call GetTempPath() then possibly create a subfolder for your >>> application, and save the file there. "Standard" apps like Visual
    Studio, Office etc. all create temp files without prompting the user
    with a dialog box.

    Mike.


    i dont want temp file so i dont fully know what you are talkin about

    i just want a quicksave say you draw image and after say 30 seconds of
    editions you pred F5 for quicksave and you got a history of editions
    in a form of many bitmaps in working directory - then you can delect
    them and delete those not needed with total commander


    Sure... if you know where you want to save the quicksaves and you're confident the user will have access to that location, no problem. [My earlier idea of putting the date/time in the filename might still be
    useful, e.g. when you come to delete the files later on with TC.]


    i though on this date too, it is easier than generating number but as i
    would also want to read those files (say like holding controll and using
    arrows left/right) the date is then slightly worse

    - though not so much as to be fullly proper i couldnt assume all
    the previous piant+ numbers are present so probably full right
    way to do it is to read directory files in the list sort and take the
    last ... its kinda a dose of work though fortunateli i got code for such
    things in my library (sickle.c)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From fir@21:1/5 to fir on Tue Mar 26 11:08:49 2024
    fir wrote:
    Mike Terry wrote:
    On 25/03/2024 18:44, fir wrote:
    Mike Terry wrote:
    On 25/03/2024 08:07, fir wrote:
    Mike Terry wrote:
    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)

    I think the bigger issue is where to create such files? If users
    have
    used your app to open some existing .bmp file for processing, it's >>>>>> quite
    possible they won't have write access to that folder. In that case a >>>>>> Save or Save As operation should trigger a standard file system file >>>>>> select dialog in a GUI program which is fair enough, but it sounds >>>>>> like
    you want to create a temp file with no user intervention? Command >>>>>> line
    utilities often have some kind of "temp folder" option.

    Ideas to consider:
    - tmpfile() (POSIX?]
    - GetTempFileName(), GetTempPath() [Windows]
    - Use environment variables like TMP/TEMP? (Possibly different
    usage
    on different platforms)
    - how to clean up such temp files so they don't pollute the file
    system
    long term?
    - ensuring uniqueness? [e.g. if multiple copies of your program are >>>>>> running at the same time]
    (Your idea is ok on this front, provided:
    * only one process can create the temp file and
    * a second open attempt with the same name will fail, and
    * your logic has a loop to recognise such failures and try again >>>>>> with a
    new name etc..
    Note GetTempFileName() fails on this front...)
    - Other filename ideas : including timestamps or GUIDs or PIDs in >>>>>> the
    filename, but by
    themselves those may not fully solve uniqueness problem.
    - Listing the directory to generate available filenames might be
    more
    efficient in some usage cases, especially if the API includes
    file
    filter options.


    the issue is that standard windows ways to do it - like chose tool
    form menu then use it, save file bny opening save dialogs - are
    terribly slow if someone want to do things wuick and fast - thats why >>>>> i like the
    programs like irfanview or total commander for example

    What you're describing is the standard windows way /for the user to
    identify a file/ e.g. an application document that the user has created >>>> and wants to save /somewhere they specify/.

    It's not the the standard windows way to create a temporary file for
    application use. For that purpose I imagine the "standard" process
    would be to call GetTempPath() then possibly create a subfolder for
    your
    application, and save the file there. "Standard" apps like Visual
    Studio, Office etc. all create temp files without prompting the user
    with a dialog box.

    Mike.


    i dont want temp file so i dont fully know what you are talkin about

    i just want a quicksave say you draw image and after say 30 seconds of
    editions you pred F5 for quicksave and you got a history of editions
    in a form of many bitmaps in working directory - then you can delect
    them and delete those not needed with total commander


    Sure... if you know where you want to save the quicksaves and you're
    confident the user will have access to that location, no problem. [My
    earlier idea of putting the date/time in the filename might still be
    useful, e.g. when you come to delete the files later on with TC.]


    i though on this date too, it is easier than generating number but as i
    would also want to read those files (say like holding controll and using arrows left/right) the date is then slightly worse

    - though not so much as to be fullly proper i couldnt assume all
    the previous piant+ numbers are present so probably full right
    way to do it is to read directory files in the list sort and take the
    last ... its kinda a dose of work though fortunateli i got code for such things in my library (sickle.c)


    see the code for list (by design i invented working on sickle.c -
    those name convention for this list is not yet quite clear as i
    generally variables and arrays wrote lettercase but here this
    list im not so sure so i used pascals


    void StrCopyMaxNBytes(char* dest, char* src, int n)
    {
    for(int i=0; i<n; i++) { dest[i]=src[i]; if(!src[i]) break; }
    }


    //list

    const int FileNameListEntry_name_max = 500;
    struct FileNameListEntry { char name[FileNameListEntry_name_max]; };

    FileNameListEntry* FileNameList = NULL;
    int FileNameList_Size = 0;

    void FileNameList_AddOne(char* name)
    {
    FileNameList_Size++;
    FileNameList = (FileNameListEntry*) realloc(FileNameList, FileNameList_Size * sizeof(FileNameListEntry) );
    StrCopyMaxNBytes((char*)&FileNameList[FileNameList_Size-1].name,
    name, FileNameListEntry_name_max);
    return ;
    }

    //tests

    void TestFileNameList()
    {
    FileNameList_AddOne("ala.bmp");
    FileNameList_AddOne("ma.bmp");
    FileNameList_AddOne("kota.bmp");

    for(int i=0; i< FileNameList_Size; i++)
    {
    printf("\n%s", FileNameList[i].name );
    }

    }

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From fir@21:1/5 to jak on Tue Mar 26 10:17:12 2024
    jak wrote:
    fir ha scritto:
    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???
    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


    I knew you would have given a similar answer but if you agree to open thousands of files to find the last of them, then you could accept that solution. It does not only do what you say because the system call is
    looking for the file for patterns and reverses the order of the list.
    All things you should do in your program. In any case, on Windows
    systems there are FindFirst/FindNext functions for this type of
    operations. Below is an example where I replace the system call with a function that uses the functions given before. The convenience of the
    system call is that on systems *nix works by simply replacing the call
    with "/usr/bin/ls -1r .......".

    #include <stdio.h>
    #include <limits.h>
    #include <stdbool.h>
    #include <windows.h>

    bool FindLastOf(char [], char *);

    int main()
    {
    char pref[] = "bmp_file_",
    f2find[50],
    str[PATH_MAX];
    int seq;
    FILE *f;

    sprintf(f2find, "%s????", pref);
    if(FindLastOf(f2find, str))
    {
    sscanf(str, "%[^0-9]%4d%*", pref, &seq);
    sprintf(str, "%s%04d", pref, ++seq);
    }
    else
    sprintf(str, "%s%04d", pref, 1);

    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);

    return 0;
    }

    bool FindLastOf(char what[], char *result)
    {
    WIN32_FIND_DATA fdF;
    HANDLE hF= NULL;
    bool ret = false;

    *result = '\0';
    if((hF = FindFirstFile(what, &fdF)) != INVALID_HANDLE_VALUE)
    {
    do
    if(strcmp(fdF.cFileName, result) > 0)
    strcpy(result, fdF.cFileName);
    while(FindNextFile(hF, &fdF));
    ret = true;
    FindClose(hF);
    }
    return ret;
    }

    Not even this piece of code is well tested and is just an example.

    Unfortunately, on the systems where the opendir/readir functions are available instead of FindFirst/FindFext, the work will be more difficult because they do not have the receipt for patterns.


    im not sure what you do your style is unclear to me esp i found name
    FindLastOf possibly misleading - what last of it founds?


    wait a bit maybe i will wrote you how i would od it i got my library
    sickle.c which is able to read list of those names to container in ram
    and then operate on this

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From fir@21:1/5 to fir on Tue Mar 26 11:59:28 2024
    fir wrote:
    see the code for list (by design i invented working on sickle.c -
    those name convention for this list is not yet quite clear as i
    generally variables and arrays wrote lettercase but here this
    list im not so sure so i used pascals


    void StrCopyMaxNBytes(char* dest, char* src, int n)
    {
    for(int i=0; i<n; i++) { dest[i]=src[i]; if(!src[i]) break; }
    }


    //list

    const int FileNameListEntry_name_max = 500;
    struct FileNameListEntry { char name[FileNameListEntry_name_max]; };

    FileNameListEntry* FileNameList = NULL;
    int FileNameList_Size = 0;

    void FileNameList_AddOne(char* name)
    {
    FileNameList_Size++;
    FileNameList = (FileNameListEntry*) realloc(FileNameList, FileNameList_Size * sizeof(FileNameListEntry) );
    StrCopyMaxNBytes((char*)&FileNameList[FileNameList_Size-1].name,
    name, FileNameListEntry_name_max);
    return ;
    }


    ok so to the addtion of container code above this work

    WIN32_FIND_DATA ffd;

    void ReadDIrectoryFileNamesToList(char* dir)
    {
    HANDLE h = FindFirstFile(dir, &ffd);
    if(!h) ERROR_EXIT("error reading directory");

    do {
    if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
    FileNameList_AddOne(ffd.cFileName);
    }
    while (FindNextFile(h, &ffd));

    }



    int main(void)
    {
    // ReadDIrectoryFileNamesToList("C:\\*");
    ReadDIrectoryFileNamesToList("*");

    for(int i=0; i< FileNameList_Size; i++)
    printf("\n %d %s", i, FileNameList[i].name );

    return 'ok';
    }

    so i got all teh names in list ..eventually i could sort it hovever i
    got bad experiences with my sorting routine

    back then i wanted to revrite quicksort to be as simpel as possible and
    cookd a form that had an error but lost the ability to say which of the
    form is correct so i had a sort of quicksort trauma now

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From fir@21:1/5 to fir on Tue Mar 26 12:02:09 2024
    fir wrote:
    jak wrote:
    fir ha scritto:
    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


    I knew you would have given a similar answer but if you agree to open
    thousands of files to find the last of them, then you could accept that
    solution. It does not only do what you say because the system call is
    looking for the file for patterns and reverses the order of the list.
    All things you should do in your program. In any case, on Windows
    systems there are FindFirst/FindNext functions for this type of
    operations. Below is an example where I replace the system call with a
    function that uses the functions given before. The convenience of the
    system call is that on systems *nix works by simply replacing the call
    with "/usr/bin/ls -1r .......".

    #include <stdio.h>
    #include <limits.h>
    #include <stdbool.h>
    #include <windows.h>

    bool FindLastOf(char [], char *);

    int main()
    {
    char pref[] = "bmp_file_",
    f2find[50],
    str[PATH_MAX];
    int seq;
    FILE *f;

    sprintf(f2find, "%s????", pref);
    if(FindLastOf(f2find, str))
    {
    sscanf(str, "%[^0-9]%4d%*", pref, &seq);
    sprintf(str, "%s%04d", pref, ++seq);
    }
    else
    sprintf(str, "%s%04d", pref, 1);

    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);

    return 0;
    }

    bool FindLastOf(char what[], char *result)
    {
    WIN32_FIND_DATA fdF;
    HANDLE hF= NULL;
    bool ret = false;

    *result = '\0';
    if((hF = FindFirstFile(what, &fdF)) != INVALID_HANDLE_VALUE)
    {
    do
    if(strcmp(fdF.cFileName, result) > 0)
    strcpy(result, fdF.cFileName);
    while(FindNextFile(hF, &fdF));
    ret = true;
    FindClose(hF);
    }
    return ret;
    }

    Not even this piece of code is well tested and is just an example.

    Unfortunately, on the systems where the opendir/readir functions are
    available instead of FindFirst/FindFext, the work will be more difficult
    because they do not have the receipt for patterns.


    im not sure what you do your style is unclear to me esp i found name FindLastOf possibly misleading - what last of it founds?


    wait a bit maybe i will wrote you how i would od it i got my library
    sickle.c which is able to read list of those names to container in ram
    and then operate on this



    i see i posted it in wrong place so here it should be

    see the code for list (by design i invented working on sickle.c -
    those name convention for this list is not yet quite clear as i
    generally variables and arrays wrote lettercase but here this
    list im not so sure so i used pascals


    void StrCopyMaxNBytes(char* dest, char* src, int n)
    {
    for(int i=0; i<n; i++) { dest[i]=src[i]; if(!src[i]) break; }
    }


    //list

    const int FileNameListEntry_name_max = 500;
    struct FileNameListEntry { char name[FileNameListEntry_name_max]; };

    FileNameListEntry* FileNameList = NULL;
    int FileNameList_Size = 0;

    void FileNameList_AddOne(char* name)
    {
    FileNameList_Size++;
    FileNameList = (FileNameListEntry*) realloc(FileNameList, FileNameList_Size * sizeof(FileNameListEntry) );
    StrCopyMaxNBytes((char*)&FileNameList[FileNameList_Size-1].name,
    name, FileNameListEntry_name_max);
    return ;
    }


    ok so to the addtion of container code above this work

    WIN32_FIND_DATA ffd;

    void ReadDIrectoryFileNamesToList(char* dir)
    {
    HANDLE h = FindFirstFile(dir, &ffd);
    if(!h) ERROR_EXIT("error reading directory");

    do {
    if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
    FileNameList_AddOne(ffd.cFileName);
    }
    while (FindNextFile(h, &ffd));

    }



    int main(void)
    {
    // ReadDIrectoryFileNamesToList("C:\\*");
    ReadDIrectoryFileNamesToList("*");

    for(int i=0; i< FileNameList_Size; i++)
    printf("\n %d %s", i, FileNameList[i].name );

    return 'ok';
    }

    so i got all teh names in list

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From jak@21:1/5 to All on Tue Mar 26 18:42:24 2024
    fir ha scritto:
    fir wrote:
    jak wrote:
    fir ha scritto:
    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???
    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


    I knew you would have given a similar answer but if you agree to open
    thousands of files to find the last of them, then you could accept that
    solution. It does not only do what you say because the system call is
    looking for the file for patterns and reverses the order of the list.
    All things you should do in your program. In any case, on Windows
    systems there are FindFirst/FindNext functions for this type of
    operations. Below is an example where I replace the system call with a
    function that uses the functions given before. The convenience of the
    system call is that on systems *nix works by simply replacing the call
    with "/usr/bin/ls -1r .......".

    #include <stdio.h>
    #include <limits.h>
    #include <stdbool.h>
    #include <windows.h>

    bool FindLastOf(char [], char *);

    int main()
    {
         char pref[] = "bmp_file_",
              f2find[50],
              str[PATH_MAX];
         int  seq;
         FILE *f;

         sprintf(f2find, "%s????", pref);
         if(FindLastOf(f2find, str))
         {
             sscanf(str, "%[^0-9]%4d%*", pref, &seq);
             sprintf(str, "%s%04d", pref, ++seq);
         }
         else
             sprintf(str, "%s%04d", pref, 1);

         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);

         return 0;
    }

    bool FindLastOf(char what[], char *result)
    {
         WIN32_FIND_DATA fdF;
         HANDLE hF= NULL;
         bool ret = false;

         *result = '\0';
         if((hF = FindFirstFile(what, &fdF)) != INVALID_HANDLE_VALUE)
         {
             do
                 if(strcmp(fdF.cFileName, result) > 0)
                     strcpy(result, fdF.cFileName);
             while(FindNextFile(hF, &fdF));
             ret = true;
             FindClose(hF);
         }
         return ret;
    }

    Not even this piece of code is well tested and is just an example.

    Unfortunately, on the systems where the opendir/readir functions are
    available instead of FindFirst/FindFext, the work will be more difficult >>> because they do not have the receipt for patterns.


    im not sure what you do your style is unclear to me esp i found name
    FindLastOf possibly misleading - what last of it founds?


    wait a bit maybe i will wrote you how i would od it i got my library
    sickle.c which is able to read list of those names to container in ram
    and then operate on this



    i see i posted it in wrong place so here it should be

    see the code for list (by design i invented working on sickle.c -
    those name convention for this list is not yet quite clear as i
    generally variables and arrays wrote lettercase but here this
    list im not so sure so i used pascals


    void StrCopyMaxNBytes(char* dest, char* src, int n)
    {
        for(int i=0; i<n; i++) { dest[i]=src[i]; if(!src[i]) break;  }
    }


       //list

       const int FileNameListEntry_name_max = 500;
       struct FileNameListEntry { char name[FileNameListEntry_name_max]; };

       FileNameListEntry* FileNameList = NULL;
       int FileNameList_Size = 0;

       void FileNameList_AddOne(char* name)
       {
           FileNameList_Size++;
           FileNameList = (FileNameListEntry*) realloc(FileNameList,
    FileNameList_Size * sizeof(FileNameListEntry) );
           StrCopyMaxNBytes((char*)&FileNameList[FileNameList_Size-1].name,
    name, FileNameListEntry_name_max);
           return ;
       }


    ok so to the addtion of container code above this work

     WIN32_FIND_DATA ffd;

     void ReadDIrectoryFileNamesToList(char* dir)
     {
      HANDLE h = FindFirstFile(dir, &ffd);
      if(!h) ERROR_EXIT("error reading directory");

      do  {
       if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
         FileNameList_AddOne(ffd.cFileName);
      }
      while (FindNextFile(h, &ffd));

     }



    int main(void)
    {
    //  ReadDIrectoryFileNamesToList("C:\\*");
      ReadDIrectoryFileNamesToList("*");

      for(int i=0; i< FileNameList_Size; i++)
          printf("\n %d %s", i, FileNameList[i].name );

      return 'ok';
    }

    so i got all teh names in list

    ok. Your code creates a list with all the file names. If I run mine,
    however, it looks for the alphabetically greater file with
    "bmp_File_????" search-pattern, acquires the Counter from the name and increases it to give the name to the next file, then creates it. So if
    you run the program in an empty directory the first time it will create
    a file called "bmp_file_0001" and every time you run the file in the
    same directory it will create a new file with the counter increased.

    bmp_File_0001
    bmp_File_0002
    bmp_File_0003
    bmp_File_0004
    bmp_File_0005
    and so on...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From jak@21:1/5 to All on Wed Mar 27 11:15:13 2024
    fir ha scritto:

    i do not love to much those clib functions on working on strings and
    memcopy etc and i rather write my own (except printf, sprintf)

    I don't like those functions too. I only use them for attempts and
    examples to reduce code lines.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From fir@21:1/5 to jak on Wed Mar 27 11:00:19 2024
    jak wrote:
    fir ha scritto:
    fir wrote:
    jak wrote:
    fir ha scritto:
    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???
    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


    I knew you would have given a similar answer but if you agree to open
    thousands of files to find the last of them, then you could accept that >>>> solution. It does not only do what you say because the system call is
    looking for the file for patterns and reverses the order of the list.
    All things you should do in your program. In any case, on Windows
    systems there are FindFirst/FindNext functions for this type of
    operations. Below is an example where I replace the system call with a >>>> function that uses the functions given before. The convenience of the
    system call is that on systems *nix works by simply replacing the call >>>> with "/usr/bin/ls -1r .......".

    #include <stdio.h>
    #include <limits.h>
    #include <stdbool.h>
    #include <windows.h>

    bool FindLastOf(char [], char *);

    int main()
    {
    char pref[] = "bmp_file_",
    f2find[50],
    str[PATH_MAX];
    int seq;
    FILE *f;

    sprintf(f2find, "%s????", pref);
    if(FindLastOf(f2find, str))
    {
    sscanf(str, "%[^0-9]%4d%*", pref, &seq);
    sprintf(str, "%s%04d", pref, ++seq);
    }
    else
    sprintf(str, "%s%04d", pref, 1);

    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);

    return 0;
    }

    bool FindLastOf(char what[], char *result)
    {
    WIN32_FIND_DATA fdF;
    HANDLE hF= NULL;
    bool ret = false;

    *result = '\0';
    if((hF = FindFirstFile(what, &fdF)) != INVALID_HANDLE_VALUE)
    {
    do
    if(strcmp(fdF.cFileName, result) > 0)
    strcpy(result, fdF.cFileName);
    while(FindNextFile(hF, &fdF));
    ret = true;
    FindClose(hF);
    }
    return ret;
    }

    Not even this piece of code is well tested and is just an example.

    Unfortunately, on the systems where the opendir/readir functions are
    available instead of FindFirst/FindFext, the work will be more
    difficult
    because they do not have the receipt for patterns.


    im not sure what you do your style is unclear to me esp i found name
    FindLastOf possibly misleading - what last of it founds?


    wait a bit maybe i will wrote you how i would od it i got my library
    sickle.c which is able to read list of those names to container in ram
    and then operate on this



    i see i posted it in wrong place so here it should be

    see the code for list (by design i invented working on sickle.c -
    those name convention for this list is not yet quite clear as i
    generally variables and arrays wrote lettercase but here this
    list im not so sure so i used pascals


    void StrCopyMaxNBytes(char* dest, char* src, int n)
    {
    for(int i=0; i<n; i++) { dest[i]=src[i]; if(!src[i]) break; }
    }


    //list

    const int FileNameListEntry_name_max = 500;
    struct FileNameListEntry { char name[FileNameListEntry_name_max]; };

    FileNameListEntry* FileNameList = NULL;
    int FileNameList_Size = 0;

    void FileNameList_AddOne(char* name)
    {
    FileNameList_Size++;
    FileNameList = (FileNameListEntry*) realloc(FileNameList,
    FileNameList_Size * sizeof(FileNameListEntry) );
    StrCopyMaxNBytes((char*)&FileNameList[FileNameList_Size-1].name,
    name, FileNameListEntry_name_max);
    return ;
    }


    ok so to the addtion of container code above this work

    WIN32_FIND_DATA ffd;

    void ReadDIrectoryFileNamesToList(char* dir)
    {
    HANDLE h = FindFirstFile(dir, &ffd);
    if(!h) ERROR_EXIT("error reading directory");

    do {
    if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
    FileNameList_AddOne(ffd.cFileName);
    }
    while (FindNextFile(h, &ffd));

    }



    int main(void)
    {
    // ReadDIrectoryFileNamesToList("C:\\*");
    ReadDIrectoryFileNamesToList("*");

    for(int i=0; i< FileNameList_Size; i++)
    printf("\n %d %s", i, FileNameList[i].name );

    return 'ok';
    }

    so i got all teh names in list

    ok. Your code creates a list with all the file names. If I run mine,
    however, it looks for the alphabetically greater file with
    "bmp_File_????" search-pattern, acquires the Counter from the name and increases it to give the name to the next file, then creates it. So if
    you run the program in an empty directory the first time it will create
    a file called "bmp_file_0001" and every time you run the file in the
    same directory it will create a new file with the counter increased.

    bmp_File_0001
    bmp_File_0002
    bmp_File_0003
    bmp_File_0004
    bmp_File_0005
    and so on...

    ok, though you use quite different style of c coding compared to my

    i would - after reading the list probably write somethuing like
    int n = GetNumberFromNumberedBitmapName(char* name);
    run it in loop over the list store the maximum found and generate the
    new name based on that

    i do not love to much those clib functions on working on strings and
    memcopy etc and i rather write my own (except printf, sprintf)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From fir@21:1/5 to jak on Wed Mar 27 12:59:51 2024
    jak wrote:
    fir ha scritto:

    i do not love to much those clib functions on working on strings and
    memcopy etc and i rather write my own (except printf, sprintf)

    I don't like those functions too. I only use them for attempts and
    examples to reduce code lines.


    still you could write names in pascal i guess thet describe what they do becouse honsetly seing them i dont know immediatelly what they do as
    i dont know them all (as i not use them or rarely)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From fir@21:1/5 to Mike Terry on Thu Mar 28 00:33:53 2024
    Mike Terry wrote:
    On 25/03/2024 18:44, fir wrote:
    Mike Terry wrote:
    On 25/03/2024 08:07, fir wrote:
    Mike Terry wrote:
    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)

    I think the bigger issue is where to create such files? If users have >>>>> used your app to open some existing .bmp file for processing, it's
    quite
    possible they won't have write access to that folder. In that case a >>>>> Save or Save As operation should trigger a standard file system file >>>>> select dialog in a GUI program which is fair enough, but it sounds
    like
    you want to create a temp file with no user intervention? Command
    line
    utilities often have some kind of "temp folder" option.

    Ideas to consider:
    - tmpfile() (POSIX?]
    - GetTempFileName(), GetTempPath() [Windows]
    - Use environment variables like TMP/TEMP? (Possibly different usage >>>>> on different platforms)
    - how to clean up such temp files so they don't pollute the file
    system
    long term?
    - ensuring uniqueness? [e.g. if multiple copies of your program are >>>>> running at the same time]
    (Your idea is ok on this front, provided:
    * only one process can create the temp file and
    * a second open attempt with the same name will fail, and
    * your logic has a loop to recognise such failures and try again >>>>> with a
    new name etc..
    Note GetTempFileName() fails on this front...)
    - Other filename ideas : including timestamps or GUIDs or PIDs in the >>>>> filename, but by
    themselves those may not fully solve uniqueness problem.
    - Listing the directory to generate available filenames might be more >>>>> efficient in some usage cases, especially if the API includes file >>>>> filter options.


    the issue is that standard windows ways to do it - like chose tool
    form menu then use it, save file bny opening save dialogs - are
    terribly slow if someone want to do things wuick and fast - thats why
    i like the
    programs like irfanview or total commander for example

    What you're describing is the standard windows way /for the user to
    identify a file/ e.g. an application document that the user has created
    and wants to save /somewhere they specify/.

    It's not the the standard windows way to create a temporary file for
    application use. For that purpose I imagine the "standard" process
    would be to call GetTempPath() then possibly create a subfolder for your >>> application, and save the file there. "Standard" apps like Visual
    Studio, Office etc. all create temp files without prompting the user
    with a dialog box.

    Mike.


    i dont want temp file so i dont fully know what you are talkin about

    i just want a quicksave say you draw image and after say 30 seconds of
    editions you pred F5 for quicksave and you got a history of editions
    in a form of many bitmaps in working directory - then you can delect
    them and delete those not needed with total commander


    Sure... if you know where you want to save the quicksaves and you're confident the user will have access to that location, no problem. [My earlier idea of putting the date/time in the filename might still be
    useful, e.g. when you come to delete the files later on with TC.]

    Mike.

    i somewhat updatet the idea

    now i would like editor for lowres animation that
    worx like this

    you start from base frame - by pressing arrow right you clone
    the image and my edit it to generate second frame of animation,
    then by pressing right you clone it to gnerate third and so on

    by pressing l;eft you get back to previous if it exist (if no you
    clone - you also should clone by pressing up and down to be
    ablo to clone more animation branches from given point

    so i think i probably will save as:

    (assume "A.bmp" is starting frame)

    "A.bmp"
    "Ar.bmp"
    "Arr.bmp"
    "Arrr.bmp"
    "Arru.bmp"
    "Arruu.bmp"
    "Arruul.bmp"
    "Arruull.bmp"

    and so on

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From jak@21:1/5 to All on Thu Mar 28 15:37:13 2024
    fir ha scritto:
    jak wrote:
    fir ha scritto:

    i do not love to much those clib functions on working on strings and
    memcopy etc and i rather write my own (except printf, sprintf)

    I don't like those functions too. I only use them for attempts and
    examples to reduce code lines.


    still you could write names in pascal i guess thet describe what they do becouse honsetly seing them i dont know immediatelly what they do as
    i dont know them all (as i not use them or rarely)


    ...and maybe I should do that using your language and not mine. :^D

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)