MCPcopy Create free account
hub / github.com/ashkulz/NppFTP / GetInfoInDOSFormat

Method GetInfoInDOSFormat

UTCP/src/ftp_c.cpp:2850–2924  ·  view source on GitHub ↗

GetInfoInDOSFormat() Although it is strongly discouraged to use DOS file format for the server directory structure. There are still the few number of FTP servers sites that provides the names in a DOS format. This function will parse the file information details based on the DOS format PARAM: CUT_DIRINFO di - the directory information entry to be populated RETURN

Source from the content-addressed store, hash-verified

2848 VOID
2849**********************************************/
2850void CUT_FTPClient::GetInfoInDOSFormat( CUT_DIRINFOA * di){
2851 //parse and store the directory information
2852 char buf[32];
2853 char bufDos[MAX_PATH+1];
2854 char dateBuf[20];
2855 long value;
2856
2857 //parse and store the directory information
2858
2859 // Get the file name
2860 int nSpaces = 0, loop = 0;
2861 while(m_szBuf[loop] != 0) {
2862 if(m_szBuf[loop] == ' ') {
2863 ++ nSpaces;
2864 while(m_szBuf[loop] == ' ')
2865 ++ loop;
2866 }
2867 else if(nSpaces == 3) {
2868 strncpy(di->fileName, &m_szBuf[loop], sizeof(di->fileName)-1);
2869 break;
2870 }
2871 else
2872 ++ loop;
2873 }
2874
2875 CUT_StrMethods::ParseString(m_szBuf, " ", 2, bufDos, sizeof(bufDos));
2876
2877 //directory attrib
2878 if(bufDos[1]=='d' || bufDos[1] =='D')
2879 di->isDir = TRUE;
2880 else
2881 di->isDir = FALSE;
2882
2883 //size portion of the file date
2884 di->fileSize = 0;
2885 CUT_StrMethods::ParseString(m_szBuf," ",2,&di->fileSize);
2886
2887
2888 //month portion of the file date
2889 di->month = 1;
2890 CUT_StrMethods::ParseString(m_szBuf," ",0,dateBuf,sizeof(dateBuf));
2891 CUT_StrMethods::ParseString(dateBuf,"-",0,buf,sizeof(buf));
2892 //find the month number from the string
2893 di->month = atoi(buf);
2894 //day portion of the file date
2895 di->day =1;
2896 CUT_StrMethods::ParseString(dateBuf,"-",1,&value);
2897 di->day = (int)value;
2898 //year and or hour portion of the file date
2899 di->year = 1900;
2900 di->hour = 12;
2901 di->minute = 0;
2902 CUT_StrMethods::ParseString(m_szBuf," ",0,dateBuf,sizeof(dateBuf));
2903
2904 strncpy(dateBuf, &dateBuf[6],2);
2905 dateBuf[2] = '\0';
2906
2907 int temp = atoi(dateBuf);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected