Coder Social home page Coder Social logo

Wierd Issue observed when reading files with filenames of 13 with same name as a subfolder in the volume working directory. about sdfat HOT 5 CLOSED

greiman avatar greiman commented on July 22, 2024
Wierd Issue observed when reading files with filenames of 13 with same name as a subfolder in the volume working directory.

from sdfat.

Comments (5)

greiman avatar greiman commented on July 22, 2024

I am not sure what this means:

Only occurs when a sub-folder of the same name as the the bitmap I'm trying to access exist together within the same working directory.

You can't have a sub-folder and file with the same name in a folder.

If you try to do this with Windows 10, it is not allowed an you get the error message:

There is already a folder with the same name as the file name you specified. Specify a different name.

from sdfat.

paqwa avatar paqwa commented on July 22, 2024

Hi Bill, thanks for your response. Sorry for not being clearer when describing the issue. Of course you cannot have two files/folders with exactly the same name in the same folder. What I meant was the file and folder have the same name when you exclude the file extension. With the extension included the filename is different to the folder. As an example the folder could be called:

abcdefghijklmno

and the file called

abcdefghijklmno.bmp

I hope this makes sense?

from sdfat.

greiman avatar greiman commented on July 22, 2024

Try this test program. When I run it, it prints this:

Type any character
         0 abcdefghijklmno/
       156 abcdefghijklmno.bmp
Done
#include <SPI.h>
#include "SdFat.h"

#define FOLDER_NAME "abcdefghijklmno"
#define FILE_NAME "abcdefghijklmno.bmp"

//SdFatSdio SD;
SdFatSdioEX SD;

File file;

void setup() {
  Serial.begin(9600);
  while (!Serial) {}
  Serial.println("Type any character");
  while (!Serial.available());
  if (!SD.begin()) {
    Serial.println("begin failed");
    return;
  }
  if (!SD.exists(FOLDER_NAME)) {
    if (!SD.mkdir(FOLDER_NAME)) {
      Serial.println("mkdir failed");
      return;
    }
  }
  if (!SD.exists(FILE_NAME)) {
    if (!file.open(FILE_NAME, O_WRITE | O_CREAT | O_TRUNC)) {
      Serial.println("open write failed");
      return;
    }
    for (int i = 100; i < 256; i++) {
      file.write(i);
    }
    file.close();
  }
  if (!file.open(FILE_NAME, O_READ)) {
    Serial.println("open read failed");
    return;
  }
  for (int i = 100; i < 256; i++) {
    if (file.read() != i) {
      Serial.println("compare failed");
      return;
    }
  }
  SD.ls(LS_SIZE);
  Serial.println("Done");
}
void loop() {}

from sdfat.

paqwa avatar paqwa commented on July 22, 2024

Hi Bill, yes this works for me also and thanks for putting it together. It prompted me to re-analyse my code in greater depth. I wrote my code to do different things with the images depending on whether a folder of the same name existed or not and in that section of the code I made a two very rookie mistakes! I didn't allocate a long enough char array for those filenames and upon analyzing my images on the SD card I found that additional information was saved to the file header which was not being skipped over by my code, hence the read error on images.

from sdfat.

paqwa avatar paqwa commented on July 22, 2024

So it turns out my issue was just with my novice coding abilities and not with your excellent library, thanks all the same for your responses and guidance on the matter. I will close this issue now.

All the best,
Pat

from sdfat.

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.