void SDCardEntry::setFromParentEntry(SDCardEntry *parent) { m_strncpy(dir, parent->dir, sizeof(dir)); m_strnappend(dir, parent->dir_entry.long_name, sizeof(dir)); m_strncpy(name, dir_entry.long_name, sizeof(name)); exists = true; }
char *m_strcat(char *string1, char *string2) { int len1 = m_strlen(string1, ""); int len2 = m_strlen(string2, ""); char *ptr = m_malloc(len1 + len2 + 1); if (ptr == NULL) return (NULL); m_strncpy(ptr, string1, len1); m_strncpy(&ptr[len1], string2, len2); ptr[len1 + len2] = 0; return (ptr); }
bool SDCardEntry::setPath(const char *path) { exists = SDCard.findFile(path, this); const char *pos = strrchr(path, '/'); if (pos != NULL) { uint8_t len = MIN(sizeof(dir), (uint16_t)(pos - path)); if (len == 0) { m_strncpy(dir, "/", sizeof(dir)); } else { m_strncpy(dir, path, len); } m_strncpy(name, pos + 1, sizeof(name)); } else { m_strncpy(dir, path, sizeof(dir)); } return exists; }
char * is_head (unsigned char * s1, unsigned char * s2) { char s[200]; // should be enough int l = strlen(s1); if (l > 199) l = 199; m_strncpy (s, s2, l); s[l] = 0; return m_stricmp (s, s1) ? NULL : s2 + l; }
void getNotePitch(uint8_t pitch, char *name) { int8_t octave = pitch / 12 - 1; uint8_t note = pitch % 12; m_strncpy(name, noteNames[note], 2); if (octave < 0) { name[2] = '-'; name[3] = '0' - octave; name[4] = '\0'; } else { name[2] = octave + '0'; name[3] = '\0'; } }
bool SDCardEntry::createSubDirectory(const char *path, struct fat_dir_entry_struct *new_entry) { if (path[0] == '/') path++; fat_dir_struct *dd = fat_open_dir(SDCard.fs, &dir_entry); if (dd == NULL) return false; char subDir[64]; while (1) { const char *pos = strchr(path, '/'); if (pos == NULL) { m_strncpy(subDir, path, sizeof(subDir) - 1); } else { int len = pos - path; memcpy(subDir, path, len); subDir[len] = '\0'; path = pos + 1; } struct fat_dir_entry_struct new_dir_entry; int result = fat_create_dir(dd, subDir, &new_dir_entry); if (result == 0 && strcmp(subDir, new_dir_entry.long_name)) { fat_close_dir(dd); return false; } else { memcpy(new_entry, &new_dir_entry, sizeof(new_dir_entry)); fat_close_dir(dd); dd = fat_open_dir(SDCard.fs, &new_dir_entry); if (dd == NULL) { return false; } else { if (pos == NULL) { sd_raw_sync(); fat_close_dir(dd); return true; } } } } }
char *getNameModalGui(char *line1, char *initName) { m_strncpy(nameModalGuiPage.line1, line1, 16); return nameModalGuiPage.getName(initName); }
void m_strcpy(char *dest, char *src) { m_strncpy(dest, src, m_strlen(src, "")); }