On 9/14/20 8:32 PM, John R. Hogerhuis wrote:


On Mon, Sep 14, 2020 at 3:47 PM Brian K. White <b.kenyo...@gmail.com <mailto:b.kenyo...@gmail.com>> wrote:


        while(s[j] == 0x00) j--;            // seek from end to non-null
        if(s[j] == '/' && j > 0x00) j--;    // seek past trailing slash
        z = j;                              // mark end of name
        while(s[j] != '/' && j > 0x00) j--; // seek to next slash


Yipes, yeah... cowboy might want to keep an eye on 'j'.

-- John.


You're right about the bounds checking but I thought the main problem might be that it's only looking for '/' and not looking also for '\'.

Looks like I just copied that bit from Jimmy.

https://github.com/TangentDelta/SD2TPDD/blob/master/SD2TPDD.ino

----------
void upDirectory(){ //Removes the top-most entry in the directoy path
  int j = sizeof(directory);

  while(directory[j] == 0x00){ //Jump to first non-null character
    j--;
  }

  if(directory[j] == '/' && j!= 0x00){  //Strip away the slash character
    directory[j] = 0x00;
  }

while(directory[j] != '/'){ //Move towards the front of the array until a slash character is encountered... directory[j--] = 0x00; //...set everything along the way to null characters
  }
}
----------

--
bkw

Reply via email to