/// <summary> /// 注册获取当前播放时间的回调 /// </summary> /// <param name="cb"></param> /// <returns><c>true</c> 调用成功, <c>false</c> 调用失败</returns> public static bool RegGetPlayCurrentPositionCb(StatusCallbackDelegate cb) { #if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX return(false); #else if (!_initialized) { return(false); } var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb); return(AudioNativeMethods.nim_audio_reg_get_play_current_position_cb(OnCancelCaptureCallback, ptr)); #endif }
/// <summary> /// 注册获取当前录制时间的回调 /// </summary> /// <param name="cb"></param> /// <returns><c>true</c> 调用成功, <c>false</c> 调用失败</returns> public static bool RegGetCaptureTimeCb(StatusCallbackDelegate cb) { #if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX return(false); #else if (!_initialized) { return(false); } var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb); return(AudioNativeMethods.nim_audio_reg_get_capture_time_cb(OnGetCaptureTimeCallback, ptr)); #endif }
/// <summary> /// Generate the sync preview containing actions to be executed. /// The returned SyncPreviewResult can then be passed to Synchronize method /// as an argument for the actions to be executed. /// </summary> /// <exception cref="DirectoryNotFoundException"></exception> public SyncPreviewResult GenerateSyncPreview(StatusCallbackDelegate statusCallback) { OnStatusChanged(new SyncStatusChangedEventArgs(m_ResourceManager.GetString("lbl_peparingToSync"))); // Load actions to be executed. IList <SyncAction> actions = actProvider.Load(_job.SyncSource.ID, SourceOption.SOURCE_ID_NOT_EQUALS); // Generate current folder's metadata FileMetaData currentItems = MetaDataProvider.GenerateFileMetadata(_job.SyncSource.Path, _job.SyncSource.ID, false, statusCallback); // Load current folder metadata from database FileMetaData oldCurrentItems = mdProvider.LoadFileMetadata(_job.SyncSource.ID, SourceOption.SOURCE_ID_EQUALS); // Load the other folder metadata from database FileMetaData oldOtherItems = mdProvider.LoadFileMetadata(_job.SyncSource.ID, SourceOption.SOURCE_ID_NOT_EQUALS); return(new SyncPreviewResult(actions, currentItems, oldCurrentItems, oldOtherItems)); }
public static FileMetaData GenerateFileMetadata(string fromPath, string id, bool excludeHidden, StatusCallbackDelegate statusCallback) { FileMetaData fileMetadata = new FileMetaData(id, fromPath); DirectoryInfo di = new DirectoryInfo(fromPath); AddDirectorySecurity(fromPath); FileInfo[] files = null; if (statusCallback != null) { statusCallback("Reading files from: " + fromPath); } files = di.GetFiles("*.*", SearchOption.AllDirectories); if (files == null) { return(new FileMetaData(id, fromPath)); } IEnumerable <FileInfo> noHiddenFiles = from file in files where excludeHidden ? !Files.FileUtils.IsFileHidden(file.FullName) : true select file; files = noHiddenFiles.ToArray <FileInfo>(); foreach (FileInfo f in files) { try { if (statusCallback != null) { statusCallback(string.Format("Processing file: {0}", f.FullName)); } fileMetadata.MetaDataItems.Add(new FileMetaDataItem(id, OneSync.Files.FileUtils.GetRelativePath(fromPath, f.FullName), Files.FileUtils.GetFileHash(f.FullName), f.LastWriteTime, (uint)0, (uint)0)); }catch (Exception) { } } return(fileMetadata); }
/// <summary> /// Generate the sync preview containing actions to be executed. /// The returned SyncPreviewResult can then be passed to Synchronize method /// as an argument for the actions to be executed. /// </summary> /// <exception cref="DirectoryNotFoundException"></exception> public SyncPreviewResult GenerateSyncPreview(StatusCallbackDelegate statusCallback) { OnStatusChanged(new SyncStatusChangedEventArgs(m_ResourceManager.GetString("lbl_peparingToSync"))); // Load actions to be executed. IList<SyncAction> actions = actProvider.Load(_job.SyncSource.ID, SourceOption.SOURCE_ID_NOT_EQUALS); // Generate current folder's metadata FileMetaData currentItems = MetaDataProvider.GenerateFileMetadata(_job.SyncSource.Path, _job.SyncSource.ID, false, statusCallback); // Load current folder metadata from database FileMetaData oldCurrentItems = mdProvider.LoadFileMetadata(_job.SyncSource.ID, SourceOption.SOURCE_ID_EQUALS); // Load the other folder metadata from database FileMetaData oldOtherItems = mdProvider.LoadFileMetadata(_job.SyncSource.ID, SourceOption.SOURCE_ID_NOT_EQUALS); return new SyncPreviewResult(actions, currentItems, oldCurrentItems, oldOtherItems); }
public static FileMetaData GenerateFileMetadata(string fromPath, string id, bool excludeHidden, StatusCallbackDelegate statusCallback) { FileMetaData fileMetadata = new FileMetaData(id, fromPath); DirectoryInfo di = new DirectoryInfo(fromPath); AddDirectorySecurity(fromPath); FileInfo[] files = null; if (statusCallback != null) statusCallback("Reading files from: " + fromPath); files = di.GetFiles("*.*", SearchOption.AllDirectories); if (files == null) return new FileMetaData(id, fromPath); IEnumerable<FileInfo> noHiddenFiles = from file in files where excludeHidden ? !Files.FileUtils.IsFileHidden(file.FullName) : true select file; files = noHiddenFiles.ToArray<FileInfo>(); foreach (FileInfo f in files) { try { if (statusCallback != null) statusCallback(string.Format("Processing file: {0}", f.FullName)); fileMetadata.MetaDataItems.Add(new FileMetaDataItem(id, OneSync.Files.FileUtils.GetRelativePath(fromPath, f.FullName), Files.FileUtils.GetFileHash(f.FullName), f.LastWriteTime, (uint)0, (uint)0)); }catch(Exception){ } } return fileMetadata; }