OpenCores
URL https://opencores.org/ocsvn/plasma/plasma/trunk

Subversion Repositories plasma

[/] [plasma/] [trunk/] [kernel/] [filesys.c] - Diff between revs 424 and 425

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 424 Rev 425
Line 441... Line 441...
   rc = FileOpen(directory, NULL, NULL);            //Open root directory
   rc = FileOpen(directory, NULL, NULL);            //Open root directory
   for(;;)
   for(;;)
   {
   {
      if(name[0] == '/')
      if(name[0] == '/')
         ++name;
         ++name;
      for(length = 0; length < FILE_NAME_SIZE; ++length)
      for(length = 0; length < FILE_NAME_SIZE-1; ++length)
      {
      {
         if(name[length] == 0 || name[length] == '/')
         if(name[length] == 0 || name[length] == '/')
            break;
            break;
         filename[length] = name[length];
         filename[length] = name[length];
      }
      }
Line 655... Line 655...
   OS_FILE *dir;
   OS_FILE *dir;
   char fullname[FULL_NAME_SIZE];
   char fullname[FULL_NAME_SIZE];
   int rc;
   int rc;
 
 
   dir = OS_fopen(name, "r");
   dir = OS_fopen(name, "r");
 
   if(dir == NULL)
 
      return 0;
   for(;;)
   for(;;)
   {
   {
      rc = OS_fdir(dir, (char*)&fileEntry);
      rc = OS_fdir(dir, (char*)&fileEntry);
      if(rc)
      if(rc)
         break;
         break;
Line 682... Line 684...
   char *buf;
   char *buf;
   int count;
   int count;
   int i, j;
   int i, j;
 
 
   buf = (char*)malloc(5000);
   buf = (char*)malloc(5000);
 
   if(buf == NULL)
 
      return -1;
   memset(buf, 0, 5000);
   memset(buf, 0, 5000);
   for(count = 0; count < 4000; ++count)
   for(count = 0; count < 4000; ++count)
      buf[count] = (char)('A' + (count % 26));
      buf[count] = (char)('A' + (count % 26));
   OS_fmkdir("dir");
   OS_fmkdir("dir");
   OS_fmkdir("/dir/subdir");
   OS_fmkdir("/dir/subdir");
   file = OS_fopen("/dir/subdir/test.txt", "w");
   file = OS_fopen("/dir/subdir/test.txt", "w");
 
   if(file == NULL)
 
      return -1;
   count = OS_fwrite(buf, 1, 4000, file);
   count = OS_fwrite(buf, 1, 4000, file);
   OS_fclose(file);
   OS_fclose(file);
   memset(buf, 0, 5000);
   memset(buf, 0, 5000);
   file = OS_fopen("/dir/subdir/test.txt", "r");
   file = OS_fopen("/dir/subdir/test.txt", "r");
 
   if(file == NULL)
 
      return -1;
   count = OS_fread(buf, 1, 5000, file);
   count = OS_fread(buf, 1, 5000, file);
   OS_fclose(file);
   OS_fclose(file);
   printf("(%s)\n", buf);
   printf("(%s)\n", buf);
 
 
   DirRecursive("/");
   DirRecursive("/");
Line 706... Line 714...
      OS_fmkdir(buf);
      OS_fmkdir(buf);
      for(j = 0; j < 5; ++j)
      for(j = 0; j < 5; ++j)
      {
      {
         sprintf(buf, "/dir%d/file%d%d", i, i, j);
         sprintf(buf, "/dir%d/file%d%d", i, i, j);
         file = OS_fopen(buf, "w");
         file = OS_fopen(buf, "w");
 
         if(file)
 
         {
         sprintf(buf, "i=%d j=%d", i, j);
         sprintf(buf, "i=%d j=%d", i, j);
         OS_fwrite(buf, 1, 8, file);
         OS_fwrite(buf, 1, 8, file);
         OS_fclose(file);
         OS_fclose(file);
      }
      }
   }
   }
 
   }
 
 
   OS_fdelete("/dir1/file12");
   OS_fdelete("/dir1/file12");
   DirRecursive("/");
   DirRecursive("/");
   file = OS_fopen("/baddir/myfile.txt", "w");
   file = OS_fopen("/baddir/myfile.txt", "w");
   if(file)
   if(file)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.