Code Monkey home page Code Monkey logo

Comments (8)

girishnand avatar girishnand commented on June 2, 2024

In this function -



/*!
 * \brief Populates element with a path string (internal use only!)
 *
 * \param[out] element element name
 * \param tmp TRUE to use G_make_mapset_element_tmp() instead of
 * G_make_mapset_element()
 */
void G__temp_element(char *element, int tmp)
{
    const char *machine;

    strcpy(element, ".tmp");
    machine = G__machine_name();
    if (machine != NULL && *machine != 0) {
        strcat(element, "/");
        strcat(element, machine);
    }

    if (!tmp)
        G_make_mapset_object_group(element);
    else
        G_make_mapset_object_group_tmp(element);

    G_debug(2, "G__temp_element(): %s (tmp=%d)", element, tmp);
}

strcat(element, "/");
should be

strcat(element, HOST_DIRSEP );

from grass.

hellik avatar hellik commented on June 2, 2024

Windows file paths should use backward and not forward slashes.

since ages, MS Windows itself supports both, backward and forward slashes:

C:\>cd d://wd
C:\>d:
d:\wd>cd ..
d:\>c:
C:\>cd d:\\wd
C:\>d:
d:\wd>

from grass.

girishnand avatar girishnand commented on June 2, 2024

Apparently, not on my machine.

C:\Users\Girish>dir c:\mydata\grassscripts\script1.txt
 Volume in drive C is OS
 Volume Serial Number is C84E-E522

 Directory of c:\mydata\grassscripts

12-12-2023  14:35            29,373 script1.txt
               1 File(s)         29,373 bytes
               0 Dir(s)  234,900,754,432 bytes free

C:\Users\Girish>dir c:/mydata/grassscripts\script1.txt
Invalid switch - "mydata".

C:\Users\Girish>dir c:/mydata/grassscripts/script1.txt
Invalid switch - "mydata".

C:\Users\Girish>dir c:\mydata\grassscripts/script1.txt
Parameter format not correct - "script1.txt".

C:\Users\Girish>ver

Microsoft Windows [Version 10.0.22621.2715]

C:\Users\Girish>

It appears to parse correctly as long as it sees backslashes, but fails at the first forward slash in the path.

regards,

from grass.

neteler avatar neteler commented on June 2, 2024

strcat(element, "/"); should be

strcat(element, HOST_DIRSEP );

Would it harm to change this, @hellik (others) ?

from grass.

nilason avatar nilason commented on June 2, 2024

strcat(element, "/"); should be
strcat(element, HOST_DIRSEP );

Would it harm to change this, @hellik (others) ?

Wouldn't do any harm I think, it is also used elsewhere without complications. Probably safer that way. I'm curious however why this hasn't been an issue so far (with g.tempfile).

from grass.

hellik avatar hellik commented on June 2, 2024

Apparently, not on my machine.

C:\Users\Girish>dir c:\mydata\grassscripts\script1.txt
 Volume in drive C is OS
 Volume Serial Number is C84E-E522

 Directory of c:\mydata\grassscripts

12-12-2023  14:35            29,373 script1.txt
               1 File(s)         29,373 bytes
               0 Dir(s)  234,900,754,432 bytes free

C:\Users\Girish>dir c:/mydata/grassscripts\script1.txt
Invalid switch - "mydata".

C:\Users\Girish>dir c:/mydata/grassscripts/script1.txt
Invalid switch - "mydata".

C:\Users\Girish>dir c:\mydata\grassscripts/script1.txt
Parameter format not correct - "script1.txt".

C:\Users\Girish>ver

Microsoft Windows [Version 10.0.22621.2715]

C:\Users\Girish>

It appears to parse correctly as long as it sees backslashes, but fails at the first forward slash in the path.

regards,

After c: there should be // or \ (2 slashes) then it should work.

from grass.

hellik avatar hellik commented on June 2, 2024

strcat(element, "/"); should be
strcat(element, HOST_DIRSEP );

Would it harm to change this, @hellik (others) ?

Should work, and save.

from grass.

neteler avatar neteler commented on June 2, 2024

There are at least four instances to be updated then::

ag 'element, "/"'
lib/display/r_raster.c
111:            strcat(element, "/");
113:            strcat(element, "/");

lib/gis/tempfile.c
166:        strcat(element, "/");
192:        strcat(element, "/");

from grass.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.