static int sd_fat_chdir_r (struct _reent *r, const char *name) { sd_fat_private_t *dev = sd_fat_get_device_data(name); if(!dev) { r->_errno = ENODEV; return -1; } OSLockMutex(dev->pMutex); char *real_path = sd_fat_real_path(name, dev); if(!real_path) { r->_errno = ENOMEM; OSUnlockMutex(dev->pMutex); return -1; } int result = FSChangeDir(dev->pClient, dev->pCmd, real_path, -1); free(real_path); OSUnlockMutex(dev->pMutex); if(result < 0) { r->_errno = result; return -1; } return 0; }
int __wut_fs_chdir(struct _reent *r, const char *name) { FSStatus rc; if (name == NULL) { return -1; } char *path = __wut_fs_fixpath(r, name); if (!path) { r->_errno = ENOMEM; return -1; } // Set up command block FSCmdBlock fsCmd; FSInitCmdBlock(&fsCmd); rc = FSChangeDir(__wut_devoptab_fs_client, &fsCmd, path, -1); free(path); if (rc >= 0) { return 0; } r->_errno = __wut_fs_translate_error(rc); return -1; }
static int FSDrvChdir(struct _reent* r, const char* name) { FSStatus err = FSChangeDir(fsClient, fsCmdBlock, name, FS_RET_ALL_ERROR); if(err != FS_STATUS_OK) { FSDrvReportError(r); return -1; } return 0; }
//////////////////////////////////////////////////////////////////////// // //> Name: RETCODE _reentrant LFNConstructFileName() // // Type: Function // // Description: Created a Unicode string for the file described by // the LFN_FILE_LOCATOR object that it is passed. // // Inputs: 1. Pointer to a LFN_FILE_LOCATOR // 2. Pointer to an output buffer. LFNs can be up to 255 // characters so make sure the buffer is that large. No error // checking is done for overflow. // // Outputs: returns the length of the Unicode string that is created // by returnung the length the programmer is allowed to do things // like: // if(LFNConstructFileName(...)) //this will fail the conditional if the // LFN does not exists! // //< ///////////////////////////////////////////////////////////////////////// RETCODE _reentrant LFNConstructFileName(LFN_FILE_LOCATOR* LFNFileLocator,UCS3* Buffer){ int i=1; int j=0; int LFNStringOffset = 0; LFN *pLFNfcb = &DirLfn; while(1){ if(LFNFileLocator->wFCBEntry-i >=0){ //make sure we don't try and read a negative directory entry //the next line populates the DirLfn data structure with pertinent LFN data FSReadLFNRecord(LFNFileLocator->bDevice,LFNFileLocator->wFCBEntry-i); if(i==1){ //only occurs once per file (i only equals 1 the first iteration of the loop). if((pLFNfcb->m_wSignature & 0x0000FF) != 0x000001 && (pLFNfcb->m_wSignature & 0x0000FF) != 0x000041){ //in this case there is no LFN entry Buffer[0] = 0; FSChangeDir(0,LFNFileLocator->bDevice); //change directory to root return 0; } } if(pLFNfcb->m_wAttributes != 0x00000F){ Buffer[LFNStringOffset] = 0; //null terminator FSChangeDir(0,LFNFileLocator->bDevice); return LFNStringOffset; } } else{ Buffer[LFNStringOffset] = 0; //null terminator FSChangeDir(0,LFNFileLocator->bDevice); //change directory to root return LFNStringOffset; } for(j=0;j<5;j++){ //5 chars Buffer[LFNStringOffset++] = GetUnicodeCharacter(pLFNfcb->m_wFileName1,j); } for(j=0;j<6;j++){ //6 chars Buffer[LFNStringOffset++] = GetUnicodeCharacter(pLFNfcb->m_wFileName2,j); } for(j=0;j<2;j++){ //2 chars Buffer[LFNStringOffset++] = GetUnicodeCharacter(pLFNfcb->m_wFileName3,j); } i++; } }
//////////////////////////////////////////////////////////////////////////////// // Function: void _reentrant RecordTestFile(void); // Inputs: no register inputs // globals: g_RecorderSettings g_iPlaySet // Outputs: no register outputs // Description: Record one test file and display encoder format, bitrate, // and samplerate while recording // void _reentrant RecordTestFile(void) { INT iEvent; INT iCount = 0; union DisplayHints DisplayHints; BOOL bDone = FALSE; WORD wSeparator = DIRECTORY_SEPARATOR; BOOL bSendToRecorderStateMachine; INT iDestination = g_RecorderSettings[g_ADCsource].m_iDestinationDevice; INT iEncodertype = g_RecorderSettings[g_ADCsource].m_EncoderNo; _packed BYTE RecordDirectory[MAX_FOLDER_SIZE]; _packed BYTE *pDirPtr; _packed BYTE wTempStr[MAX_FOLDER_SIZE]; SysCallFunction(RSRC_PLAY_STATE_MACHINE_CODE_BANK,ExitPlayerStateMachine,1,0,0); pDirPtr = RecordDirectory; pDirPtr[0] = 0; //Add Slash packed_strcat(pDirPtr,(_packed BYTE*)(&wSeparator)); //Load Proper Directory ((WORD*)wTempStr)[0]=REC_TEST_0; //word 0 (3 chars) ((WORD*)wTempStr)[1]=REC_TEST_1; //word 1 packed_strcat(pDirPtr,(_packed BYTE*)(wTempStr));//add the directory name packed_strcat(pDirPtr,(_packed BYTE*)(&wSeparator)); //add the trailing slash // Attempt to change to the Voice directory if(FSChangeDir(RecordDirectory,iDestination)<0) { //couldn't change to the voice directory, lets try to create it. SysLoadFATWrite(); //end slash must be removed so re-initialize RecordDirectory and pointer. pDirPtr = RecordDirectory; pDirPtr[0] = 0; //Re-build RecordDirectory w/o end slash packed_strcat(pDirPtr,(_packed BYTE*)(&wSeparator)); packed_strcat(pDirPtr,(_packed BYTE*)(wTempStr));//add the directory name if(FSCreateDir(RecordDirectory,iDestination)<0) { //this verifies the creation did not fail. bDone = TRUE; } SysUnLoadFATWrite(); } if(!bDone)//if bDone is already TRUE, then we can't open the file. { g_iPlaySet = PLAYSET_VOICE; if(iEncodertype != ENCODER_MP3) { // Display recording parameters // Rate if (g_RecorderSettings[g_ADCsource].m_iSampleRateInHz == 8000) //SysPostMessage(5,LCD_PRINT_STRING_RSRC,15,0,RSRC_STRING_8000HZ); LcdPrintStringRsrc15_0(RSRC_STRING_8000HZ); else if (g_RecorderSettings[g_ADCsource].m_iSampleRateInHz == 11025) //SysPostMessage(5,LCD_PRINT_STRING_RSRC,15,0,RSRC_STRING_11025HZ); LcdPrintStringRsrc15_0(RSRC_STRING_11025HZ); else if (g_RecorderSettings[g_ADCsource].m_iSampleRateInHz == 16000) //SysPostMessage(5,LCD_PRINT_STRING_RSRC,15,0,RSRC_STRING_16000HZ); LcdPrintStringRsrc15_0(RSRC_STRING_16000HZ); else if (g_RecorderSettings[g_ADCsource].m_iSampleRateInHz == 22050) //SysPostMessage(5,LCD_PRINT_STRING_RSRC,15,0,RSRC_STRING_22050HZ); LcdPrintStringRsrc15_0(RSRC_STRING_22050HZ); else if (g_RecorderSettings[g_ADCsource].m_iSampleRateInHz == 32000) //SysPostMessage(5,LCD_PRINT_STRING_RSRC,15,0,RSRC_STRING_32000HZ); LcdPrintStringRsrc15_0(RSRC_STRING_32000HZ); else if (g_RecorderSettings[g_ADCsource].m_iSampleRateInHz == 44100) //SysPostMessage(5,LCD_PRINT_STRING_RSRC,15,0,RSRC_STRING_44100HZ); LcdPrintStringRsrc15_0(RSRC_STRING_44100HZ); else //SysPostMessage(5,LCD_PRINT_STRING_RSRC,15,0,RSRC_STRING_48000HZ); LcdPrintStringRsrc15_0(RSRC_STRING_48000HZ); // Bits SysPostMessage(6,LCD_CLEAR_RANGE,60,0,25,8);// Clear range if (g_RecorderSettings[g_ADCsource].m_ibits == 4) //SysPostMessage(5,LCD_PRINT_STRING_RSRC,70,0,RSRC_STRING_4); LcdPrintStringRsrc70_0(RSRC_STRING_4); else if (g_RecorderSettings[g_ADCsource].m_ibits == 8) //SysPostMessage(5,LCD_PRINT_STRING_RSRC,70,0,RSRC_STRING_8); LcdPrintStringRsrc70_0(RSRC_STRING_8); else if (g_RecorderSettings[g_ADCsource].m_ibits == 16) //SysPostMessage(5,LCD_PRINT_STRING_RSRC,70,0,RSRC_STRING_16); LcdPrintStringRsrc70_0(RSRC_STRING_16); else if (g_RecorderSettings[g_ADCsource].m_ibits == 24) //SysPostMessage(5,LCD_PRINT_STRING_RSRC,70,0,RSRC_STRING_24); LcdPrintStringRsrc70_0(RSRC_STRING_24); SysPostMessage(5,LCD_PRINT_STRING_RSRC,82,0,RSRC_STRING_BITS); // Format SysPostMessage(6,LCD_CLEAR_RANGE,0,8,55,8);// Clear range if (g_RecorderSettings[g_ADCsource].m_EncoderNo == ENCODER_MSADPCM) SysPostMessage(5,LCD_PRINT_STRING_RSRC,0,8,RSRC_STRING_MSADPCM); else if (g_RecorderSettings[g_ADCsource].m_EncoderNo == ENCODER_IMADPCM) SysPostMessage(5,LCD_PRINT_STRING_RSRC,0,8,RSRC_STRING_IMADPCM); else SysPostMessage(5,LCD_PRINT_STRING_RSRC,0,8,RSRC_STRING_PCM); } else { // Display recording parameters for Mp3 encoder //clear the title // SysPostMessage(6,LCD_CLEAR_RANGE,SONG_TITLE_X_POS,SONG_TITLE_Y_POS,SONG_TITLE_X_SIZE,SONG_TITLE_Y_SIZE); //Bitrate SysPostMessage(6,LCD_CLEAR_RANGE,60,0,38,8);// Clear range if(g_RecorderSettings[g_ADCsource].m_iBitRateInKbps == 96) //SysPostMessage(5,LCD_PRINT_STRING_RSRC,60,0,RSRC_STRING_96KBPS); LcdPrintStringRsrc60_0(RSRC_STRING_96KBPS); else if(g_RecorderSettings[g_ADCsource].m_iBitRateInKbps == 112) //SysPostMessage(5,LCD_PRINT_STRING_RSRC,60,0,RSRC_STRING_112KBPS); LcdPrintStringRsrc60_0(RSRC_STRING_112KBPS); else if(g_RecorderSettings[g_ADCsource].m_iBitRateInKbps == 128) //SysPostMessage(5,LCD_PRINT_STRING_RSRC,60,0,RSRC_STRING_128KBPS); LcdPrintStringRsrc60_0(RSRC_STRING_128KBPS); else if(g_RecorderSettings[g_ADCsource].m_iBitRateInKbps == 160) //SysPostMessage(5,LCD_PRINT_STRING_RSRC,60,0,RSRC_STRING_160KBPS); LcdPrintStringRsrc60_0(RSRC_STRING_160KBPS); else if(g_RecorderSettings[g_ADCsource].m_iBitRateInKbps == 192) //SysPostMessage(5,LCD_PRINT_STRING_RSRC,60,0,RSRC_STRING_192KBPS); LcdPrintStringRsrc60_0(RSRC_STRING_96KBPS); else if(g_RecorderSettings[g_ADCsource].m_iBitRateInKbps == 224) //SysPostMessage(5,LCD_PRINT_STRING_RSRC,60,0,RSRC_STRING_224KBPS); LcdPrintStringRsrc60_0(RSRC_STRING_224KBPS); else if(g_RecorderSettings[g_ADCsource].m_iBitRateInKbps == 256) //SysPostMessage(5,LCD_PRINT_STRING_RSRC,60,0,RSRC_STRING_256KBPS); LcdPrintStringRsrc60_0(RSRC_STRING_256KBPS); else //SysPostMessage(5,LCD_PRINT_STRING_RSRC,60,0,RSRC_STRING_320KBPS); LcdPrintStringRsrc60_0(RSRC_STRING_320KBPS); //sample rate if (g_RecorderSettings[g_ADCsource].m_iSampleRateInHz == 32000) //SysPostMessage(5,LCD_PRINT_STRING_RSRC,15,0,RSRC_STRING_32000HZ); LcdPrintStringRsrc15_0(RSRC_STRING_32000HZ); else if (g_RecorderSettings[g_ADCsource].m_iSampleRateInHz == 44100) //SysPostMessage(5,LCD_PRINT_STRING_RSRC,15,0,RSRC_STRING_44100HZ); LcdPrintStringRsrc15_0(RSRC_STRING_44100HZ); else //SysPostMessage(5,LCD_PRINT_STRING_RSRC,15,0,RSRC_STRING_48000HZ); LcdPrintStringRsrc15_0(RSRC_STRING_48000HZ); //Format MP3 SysPostMessage(6,LCD_CLEAR_RANGE,0,8,55,8);// Clear range SysPostMessage(5,LCD_PRINT_STRING_RSRC,0,8,RSRC_STRING_MP3); } // Channels if (g_RecorderSettings[g_ADCsource].m_iChannels == 1) SysPostMessage(5,LCD_PRINT_STRING_RSRC,60,8,RSRC_STRING_MONO); else SysPostMessage(5,LCD_PRINT_STRING_RSRC,60,8,RSRC_STRING_STEREO); // Input resource SysPostMessage(5,LCD_PRINT_STRING_RSRC,60,16,RSRC_STRING_LINEIN); SysCallFunction(RSRC_RECORDER_STATE_MACHINE_CODE_BANK,InitRecorderStateMachine,0,0,0); DisplayHints.I = RECORDTEST_DISPLAY_ALL|(1<<DISPLAY_CLEAR_DISPLAY_BITPOS); while(!bDone) { DisplayHints.I &= (RECORDTEST_DISPLAY_ALL); iEvent = SysWaitOnEvent(EVENT_MESSAGE|EVENT_BUTTON,&gEventInfo.msg,DisplayHints.I ? 1 : -1); // Above call returns when we get a message or button event bSendToRecorderStateMachine = TRUE; // send events to recorder state machine by default switch(iEvent) { case EVENT_TIMER: SysCallFunction(RSRC_DISPLAY_CODE_BANK,RefreshDisplay,DisplayHints.I,TRUE,0); DisplayHints.I= 0; bSendToRecorderStateMachine = FALSE; if (g_iEncCurrentSeconds > g_iRecordTestLength) // Record about 10 (default) seconds bDone = TRUE; break; case EVENT_BUTTON: // button pressed, so restart timer if enabled UpdateAutoShutdownTimer(); //remember the last button event (mostly for coming out of FFWD and RWND) switch(g_wLastButton = gEventInfo.Button.wButtonEvent) { case PR_MENU: case PR_STOP: bDone = TRUE; break; default: break; } break; } // end switch(iEvent) if(bSendToRecorderStateMachine) { DisplayHints.I |= SysCallFunction(RSRC_RECORDER_STATE_MACHINE_CODE_BANK,HandleRecorderStateMachine,iEvent,0,(int *) &gEventInfo); } } // end while(!bDone) SysCallFunction(RSRC_RECORDER_STATE_MACHINE_CODE_BANK,ExitRecorderStateMachine,0,0,0); } g_iPlaySet = PLAYSET_MUSIC; }