⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 file.lst

📁 sl811 c8051F驱动程序 保证绝对可以使用 USB通信协议USB1.1
💻 LST
📖 第 1 页 / 共 2 页
字号:
 199   1                      return FALSE;
 200   1              else
 201   1                      return (WORD)((Sector -  FatParameter.FirstDataSector) / SimpleBpb.SecPerClus + 2);
 202   1      }
 203          DWORD ClusterToSec(WORD Cluster)
 204          {
 205   1              if(Cluster<2)
 206   1                      return (FatParameter.FirstDataSector-1);
 207   1              return ((Cluster-2)*SimpleBpb.SecPerClus+FatParameter.FirstDataSector);
 208   1      }
 209          DWORD SeekSector(DWORD Sector, const char dirname[11], struct _FILE *file)
 210          {
 211   1              BYTE Cache[512];
 212   1              struct _DIR *dir;
 213   1              UINT j, i;
 214   1              WORD temp,temp1;
 215   1              ///////////////////////////////////////////////////////////////////////////////////     
 216   1              for(i=0; i<SimpleBpb.RootEntCnt * sizeof(struct _DIR) / SimpleBpb.BytsPerSec; i++)
 217   1              {
 218   2                      if(!Read(Sector,1,(BYTE *)Cache))
 219   2                              return  0xffffffff;                     
 220   2                      dir = (struct _DIR *)Cache;
 221   2              //********************************************************************************
 222   2                      for(j=0; (dir->Name[0] != '\0') && (j< SimpleBpb.BytsPerSec / sizeof(struct _DIR)); j++)
 223   2                      {
 224   3                              if(memcmp((const char*)dir->Name, dirname, 11)== 0)     
 225   3                              {
 226   4                                      if(file != NULL)
 227   4                                      {
 228   5                                              memset(file, 0, sizeof(struct _FILE));
 229   5                                              file->DirSectorNum = Sector;
 230   5                                              file->DirIndex = j; //j 代表了文件中该扇区中的位置(0-15);
 231   5                                              memcpy(&file->dir, dir, sizeof(struct _DIR));
 232   5                                      }
 233   4                                      temp=WordSwap(dir->FstClusLO);
 234   4                                      temp1=ClusterToSec(temp);
 235   4                                      return temp1;
 236   4                              }       
 237   3                              dir++;
 238   3                      }//end for cycle
C51 COMPILER V8.08   FILE                                                                  04/25/2009 23:03:20 PAGE 5   

 239   2                      Sector++;
 240   2              }//end for cycle
 241   1              return  0xffffffff;
 242   1      }
 243          
 244          DWORD LocateFile(const char *filename, struct _FILE *file)
 245          {
 246   1              DWORD Sector = FatParameter.FirstRootDirSecNum;
 247   1              char NewFile[12];
 248   1              char *p=NewFile;
 249   1              ///////////////////////////////////////////////////////////////////////////////
 250   1              if(!CheckFileName(filename,p))
 251   1                      return FALSE;
 252   1              Sector = SeekSector(Sector, p, file);
 253   1              if(*(p+11)==NULL)
 254   1                      return Sector;
 255   1              return 0Xffffffff;
 256   1      }
 257          BYTE LocateDir(struct _DIR* new_dir, struct _FILE * fp)
 258          {
 259   1              BYTE Cache[512];
 260   1              struct _DIR *dir;
 261   1              DWORD i;
 262   1              DWORD DirSectorNum = FatParameter.FirstRootDirSecNum;   
 263   1              ////////////////////////////////////////////////////////////////////////////////
 264   1              for(i=0; i<SimpleBpb.RootEntCnt * sizeof(struct _DIR) / SimpleBpb.BytsPerSec; i++)//total root dir sector
             -s;
 265   1              {
 266   2                      if(!Read(DirSectorNum,1,(BYTE *)Cache))
 267   2                              return FALSE;
 268   2                      /////////////////////////////////////////////////////////////////////
 269   2                      for(dir = (struct _DIR *)Cache; (BYTE*)dir < Cache + SimpleBpb.BytsPerSec; dir++)
 270   2                      {
 271   3                              if(dir->Name[0] == '\0'||dir->Name[0] == 0xE5)
 272   3                              {
 273   4                                      memcpy(dir, new_dir, sizeof(struct _DIR));      
 274   4                                      if(!Write(DirSectorNum,1,Cache,TRUE))
 275   4                                              if(!Write(DirSectorNum,1,Cache,TRUE))   
 276   4                                                      return FALSE;                           
 277   4                                      if(fp)
 278   4                                      {
 279   5                                              fp->DirSectorNum = DirSectorNum;
 280   5                                              fp->DirIndex = ((BYTE*)dir - Cache)/sizeof(struct _DIR);
 281   5                                              memcpy(&fp->dir, new_dir, sizeof(struct _DIR));
 282   5                                      }
 283   4                                      return TRUE;
 284   4                              }
 285   3                      }//--------------------------end for cycle
 286   2                       DirSectorNum++;
 287   2              }//-------------------------------end for cycle
 288   1              return FALSE; 
 289   1      }
 290          BYTE CheckFileName(const char * oldfilename,  char *newfilename[11])
 291          {
*** WARNING C235 IN LINE 291 OF FILE.C: parameter 2: different types
 292   1              char* p=newfilename;
 293   1              char path[12];
 294   1              char* ppath = path;
 295   1              int dir_len_count; //count dir len.
 296   1              int i;
 297   1              ////////////////////////////////////////////////////////////////////////////////////
 298   1              if(oldfilename==NULL || strlen(oldfilename) >=12)
C51 COMPILER V8.08   FILE                                                                  04/25/2009 23:03:20 PAGE 6   

 299   1                      return FALSE;
 300   1              dir_len_count=0;
 301   1              strcpy(path, oldfilename);
 302   1              //变小写字母为大写
 303   1              for(i=0;(*ppath!=NULL&&i<12);i++)
 304   1              {
 305   2                      if(     *ppath > 96 && *ppath < 123)
 306   2                              *ppath -= 32;   
 307   2                      ppath++;
 308   2              }
 309   1              memset(p, 0, 12);
 310   1              ppath = path;
 311   1              for(;;)
 312   1              {
 313   2                      switch(*ppath)
 314   2                      {
 315   3                      case 0:
 316   3                              {
 317   4                                      if(dir_len_count>=11)
 318   4                                              return TRUE;            
 319   4                                      else 
 320   4                                      {
 321   5                                      dir_len_count ++;
 322   5                                      *p = 0x20;
 323   5                                      p++;
 324   5                                      }
 325   4                                      continue;
 326   4                              }
 327   3                      ////////////////////////////////////////////////////////////////////////////////
 328   3                      case '.':
 329   3                              {
 330   4                                      if(dir_len_count > 8 || dir_len_count ==0)
 331   4                                      { 
 332   5                                              return FALSE;
 333   5                                      }
 334   4                                      if(ppath[1] == '.')
 335   4                                      {
 336   5                                              return FALSE;
 337   5                                      }
 338   4                                      for(i=0; i<(8 - dir_len_count); i++)
 339   4                                      {
 340   5                                              *p = 0x20;
 341   5                                              p++;
 342   5                                      }
 343   4                                      dir_len_count =8;
 344   4                                      ppath++;
 345   4                                      continue;
 346   4                                      break;
 347   4                              }
 348   3                      /////////////////////////////////////////////////////////////////////////////////
 349   3                      case 0x22:
 350   3                      case 0x2A:
 351   3                      case 0x2B:
 352   3                      case 0x2C:
 353   3                      case 0x2F:
 354   3                      case 0x3A:
 355   3                      case 0x3B:
 356   3                      case 0x3C:
 357   3                      case 0x3D:
 358   3                      case 0x3E:
 359   3                      case 0x3F:
 360   3                      case 0x5B:
C51 COMPILER V8.08   FILE                                                                  04/25/2009 23:03:20 PAGE 7   

 361   3                      case 0x5D:
 362   3                      case 0x7C:
 363   3                              return FALSE;
 364   3                      /////////////////////////////////////////////////////////////////////////////////
 365   3                      default:
 366   3                              {
 367   4                                      if(*ppath < 0x20)
 368   4                                              return FALSE;           
 369   4                                      break;  
 370   4                              }
 371   3                      ////////////////////////////////////////////////////////////////////////////////
 372   3                      }
 373   2                      *p = *ppath;
 374   2                      dir_len_count ++;
 375   2                      if(dir_len_count >= 11)
 376   2                              return TRUE;
 377   2                      p++;
 378   2                      ppath++;
 379   2              }//*end for cycle
 380   1              return FALSE;   
 381   1      }
 382          //************************************************************************
 383          //author:dragon
 384          //web:8dragon.com
 385          //2004.2.5完成于桃龙源
 386          //*************************************************************************


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   4279    ----
   CONSTANT SIZE    =      7    ----
   XDATA SIZE       =    106    2674
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
   EDATA SIZE       =   ----    ----
   HDATA SIZE       =   ----    ----
   XDATA CONST SIZE =   ----    ----
   FAR CONST SIZE   =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  1 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -