]> Chaos Git - corbenik/ctrulib.git/commitdiff
Fixed broken path code in sdmc_dev.c. Disabled attributes code in sdmc_open() for...
authoryellows8 <yellows8@users.noreply.github.com>
Mon, 17 Nov 2014 02:12:24 +0000 (21:12 -0500)
committeryellows8 <yellows8@users.noreply.github.com>
Mon, 17 Nov 2014 02:12:24 +0000 (21:12 -0500)
libctru/source/sdmc_dev.c

index 0c19de16015a45021603f10397b4c0377e4d2cd5..11b498c502cc04dfb8871d30630d4c8341f129a4 100644 (file)
@@ -141,6 +141,10 @@ sdmc_open(struct _reent *r,
   Result      rc;
   u32         sdmc_flags = 0;
   u32         attributes = FS_ATTRIBUTE_NONE;
+  char        *pathptr = NULL;
+
+  pathptr = strchr(path, '/');
+  if(pathptr==NULL)pathptr = (char*)path;
 
   /* get pointer to our data */
   sdmc_file_t *file = (sdmc_file_t*)fileStruct;
@@ -181,11 +185,11 @@ sdmc_open(struct _reent *r,
   /* TODO: Test O_EXCL. */
 
   /* set attributes */
-  if(!(mode & S_IWUSR))
-    attributes |= FS_ATTRIBUTE_READONLY;
+  /*if(!(mode & S_IWUSR))
+    attributes |= FS_ATTRIBUTE_READONLY;*/
 
   /* open the file */
-  rc = FSUSER_OpenFile(NULL, &fd, sdmcArchive, FS_makePath(PATH_CHAR, path),
+  rc = FSUSER_OpenFile(NULL, &fd, sdmcArchive, FS_makePath(PATH_CHAR, pathptr),
                        sdmc_flags, attributes);
   if(rc == 0)
   {
@@ -516,10 +520,14 @@ sdmc_mkdir(struct _reent *r,
            int           mode)
 {
   Result rc;
+  char        *pathptr = NULL;
+
+  pathptr = strchr(path, '/');
+  if(pathptr==NULL)pathptr = (char*)path;
 
   /* TODO: Use mode to set directory attributes. */
 
-  rc = FSUSER_CreateDirectory(NULL, sdmcArchive, FS_makePath(PATH_CHAR, path));
+  rc = FSUSER_CreateDirectory(NULL, sdmcArchive, FS_makePath(PATH_CHAR, pathptr));
   if(rc == 0)
     return 0;
 
@@ -543,12 +551,16 @@ sdmc_diropen(struct _reent *r,
 {
   Handle         fd;
   Result         rc;
+  char        *pathptr = NULL;
+
+  pathptr = strchr(path, '/');
+  if(pathptr==NULL)pathptr = (char*)path;
 
   /* get pointer to our data */
   sdmc_dir_t *dir = (sdmc_dir_t*)(dirState->dirStruct);
 
   /* open the directory */
-  rc = FSUSER_OpenDirectory(NULL, &fd, sdmcArchive, FS_makePath(PATH_CHAR, path));
+  rc = FSUSER_OpenDirectory(NULL, &fd, sdmcArchive, FS_makePath(PATH_CHAR, pathptr));
   if(rc == 0)
   {
     dir->fd = fd;