FILETIME FromGlkDate(const glkdate_t* date) { glsi32 carry = 0; glsi32 micros = NormalizeField(date->microsec,1000000,carry); SYSTEMTIME st; ::ZeroMemory(&st,sizeof st); st.wSecond = (WORD)NormalizeField(date->second + carry,60,carry); st.wMinute = (WORD)NormalizeField(date->minute + carry,60,carry); st.wHour = (WORD)NormalizeField(date->hour + carry,24,carry); glsi32 days = date->day + carry; st.wMonth = 1 + (WORD)NormalizeField(date->month - 1,12,carry); st.wYear = (WORD)(date->year + carry); while (days <= 0) days += LastMonth(st.wMonth,st.wYear); while (days > DaysInMonth(st.wMonth,st.wYear)) days -= NextMonth(st.wMonth,st.wYear); st.wDay = (WORD)days; FILETIME ft; if (::SystemTimeToFileTime(&st,&ft)) { ULONGLONG ticks = FileTimeToValue(ft); ticks += (micros * 10); return ValueToFileTime(ticks); } return BadTime; }
// -------------------------------------------------------------------------------- // wxString guMediaRecordCtrl::GenerateRecordFileName( void ) { wxString FileName = m_MainPath; if( !m_TrackInfo.m_AlbumName.IsEmpty() ) { FileName += NormalizeField( m_TrackInfo.m_AlbumName ); } else { wxURI Uri( m_TrackInfo.m_FileName ); FileName += NormalizeField( Uri.GetServer() + wxT( "-" ) + Uri.GetPath() ); } FileName += wxT( "/" ); if( !m_TrackInfo.m_ArtistName.IsEmpty() ) { FileName += NormalizeField( m_TrackInfo.m_ArtistName ) + wxT( " - " ); } FileName += NormalizeField( m_TrackInfo.m_SongName ) + m_Ext; //guLogDebug( wxT( "The New Record Location is : '%s'" ), FileName.c_str() ); return FileName; }
// -------------------------------------------------------------------------------- // wxString guExpandTrackMacros( const wxString &pattern, guTrack * track, const int indexpos ) { wxString RetVal = pattern; if( RetVal.Find( wxT( "{a}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{a}" ), NormalizeField( track->m_ArtistName ) ); if( RetVal.Find( wxT( "{al}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{al}" ), NormalizeField( track->m_ArtistName.Lower() ) ); if( RetVal.Find( wxT( "{au}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{au}" ), NormalizeField( track->m_ArtistName.Upper() ) ); if( RetVal.Find( wxT( "{a1}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{a1}" ), NormalizeField( track->m_ArtistName.Trim( false )[ 0 ] ) ); if( RetVal.Find( wxT( "{aa}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{aa}" ), NormalizeField( track->m_AlbumArtist ) ); if( RetVal.Find( wxT( "{aal}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{aal}" ), NormalizeField( track->m_AlbumArtist.Lower() ) ); if( RetVal.Find( wxT( "{aau}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{aau}" ), NormalizeField( track->m_AlbumArtist.Upper() ) ); if( RetVal.Find( wxT( "{aa1}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{aa1}" ), NormalizeField( track->m_AlbumArtist.Trim( false )[ 0 ] ) ); if( RetVal.Find( wxT( "{A}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{A}" ), NormalizeField( track->m_AlbumArtist.IsEmpty() ? track->m_ArtistName : track->m_AlbumArtist ) ); if( RetVal.Find( wxT( "{Al}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{Al}" ), NormalizeField( ( track->m_AlbumArtist.IsEmpty() ? track->m_ArtistName : track->m_AlbumArtist ).Lower() ) ); if( RetVal.Find( wxT( "{Au}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{Au}" ), NormalizeField( ( track->m_AlbumArtist.IsEmpty() ? track->m_ArtistName : track->m_AlbumArtist ).Upper() ) ); if( RetVal.Find( wxT( "{A1}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{A1}" ), NormalizeField( ( track->m_AlbumArtist.IsEmpty() ? track->m_ArtistName : track->m_AlbumArtist ).Trim( false )[ 0 ] ) ); if( RetVal.Find( wxT( "{b}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{b}" ), NormalizeField( track->m_AlbumName ) ); if( RetVal.Find( wxT( "{bl}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{bl}" ), NormalizeField( track->m_AlbumName.Lower() ) ); if( RetVal.Find( wxT( "{bu}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{bu}" ), NormalizeField( track->m_AlbumName.Upper() ) ); if( RetVal.Find( wxT( "{b1}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{b1}" ), NormalizeField( track->m_AlbumName.Trim( false )[ 0 ] ) ); if( RetVal.Find( wxT( "{bp}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{bp}" ), NormalizeField( track->m_FileName.BeforeLast( wxT( '/' ) ) ) ); if( RetVal.Find( wxT( "{c}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{c}" ), NormalizeField( track->m_Composer ) ); if( RetVal.Find( wxT( "{cl}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{cl}" ), NormalizeField( track->m_Composer.Lower() ) ); if( RetVal.Find( wxT( "{cu}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{cu}" ), NormalizeField( track->m_Composer.Upper() ) ); if( RetVal.Find( wxT( "{c1}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{c1}" ), NormalizeField( track->m_Composer.Trim( false )[ 0 ] ) ); if( RetVal.Find( wxT( "{f}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{f}" ), wxFileNameFromPath( track->m_FileName.BeforeLast( wxT( '.' ) ) ) ); if( RetVal.Find( wxT( "{g}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{g}" ), NormalizeField( track->m_GenreName ) ); if( RetVal.Find( wxT( "{gl}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{gl}" ), NormalizeField( track->m_GenreName.Lower() ) ); if( RetVal.Find( wxT( "{gu}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{gu}" ), NormalizeField( track->m_GenreName.Upper() ) ); if( RetVal.Find( wxT( "{g1}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{g1}" ), NormalizeField( track->m_GenreName.Trim( false )[ 0 ] ) ); if( RetVal.Find( wxT( "{n}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{n}" ), wxString::Format( wxT( "%02u" ), track->m_Number ) ); if( RetVal.Find( wxT( "{t}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{t}" ), NormalizeField( track->m_SongName ) ); if( RetVal.Find( wxT( "{tl}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{tl}" ), NormalizeField( track->m_SongName.Lower() ) ); if( RetVal.Find( wxT( "{tu}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{tu}" ), NormalizeField( track->m_SongName.Upper() ) ); if( RetVal.Find( wxT( "{y}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{y}" ), wxString::Format( wxT( "%u" ), track->m_Year ) ); if( RetVal.Find( wxT( "{d}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{d}" ), NormalizeField( track->m_Disk ) ); if( RetVal.Find( wxT( "{i}" ) ) != wxNOT_FOUND ) RetVal.Replace( wxT( "{i}" ), wxString::Format( wxT( "%04u" ), indexpos ) ); return RetVal; }