translation:working:翻訳5

差分

このページの2つのバージョン間の差分を表示します。

この比較画面にリンクする

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
translation:working:翻訳5 [2016-04-27 21:21]
Decomo
translation:working:翻訳5 [2016-08-24 13:46] (現在)
Decomo
行 50: 行 50:
 </note> </note>
  
-例えば、バックアップソフトウェアは+例えば、バックアップソフトウェアは、変更の見落としがないことを確実にするために、定期的に全てのボリュームをフルスキャンするべきです。
  
-変更がない事は無され確実にる +ルートファイルシステム上のファイルを監場合は、どちらのストリーム機構も同じような振る舞いしま
-For example, backup software should still periodically perform a full sweep of any volume to ensure that no changes fall through the cracks.+
  
-トファルシムのファイル監視る場合は、+例として、以下の<html><ruby><rb>ド片</rb><rp>(</rp><rt>snippet</rt><rp>)</rp></ruby></html>ベントトリームの生成方法示しま
  
-If you are monitoring files on the root file systemeither stream mechanism will behave similarly.+<code c> 
 +/* 監視するパスのCFStringオブジェクトを含む 
 +   CFArrayオブジェクトの変数を定義し生成する。 
 +*/ 
 +CFStringRef mypath = CFSTR("/path/to/scan"); 
 +CFArrayRef pathsToWatch = CFArrayCreate(NULL(const void **)&mypath, 1, NULL); 
 +void *callbackInfo = NULL; // ここでストリーム固有データを入れられる。 
 +FSEventStreamRef stream
 +CFAbsoluteTime latency = 3.0; /* レイテンシは秒数 */
  
-For example, the following snippet shows how to create an event stream:+/* コールバックを渡してストリームを生成する */ 
 +stream = FSEventStreamCreate(NULL, 
 +    &myCallbackFunction, 
 +    callbackInfo, 
 +    pathsToWatch, 
 +    kFSEventStreamEventIdSinceNow, /* もしくは以前のイベントID */ 
 +    latency, 
 +    kFSEventStreamCreateFlagNone /* 関数リファレンスで説明されているフラグ */ 
 +); 
 +</code>
  
-    /* Define variables and create a CFArray object containing+イベントストリームを生成した時点で、それをアプリケーションの実行ループにスケジューリングすべきです。 
 +これを行うには、生成した新規ストリーム、実行ループ、実行ループモードを引数として''FSEventStreamScheduleWithRunLoop''を呼びます。 
 +実行ループに関する更なる情報は[[https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/RunLoopManagement.html|Run Loops]]をお読み下さい。
  
-       CFString objects containing paths to watch.+もし、まだ実行ループを持っていなければ、このタスクのためにスレッドを割り当てる必要があるでしょう。 
 +あなたが選択したAPIを使ってスレッドを生成した後は、そのスレッドに最初の実行ループを確保するために''CFRunLoopGetCurrent''を呼びます。 
 +以後''CFRunLoopGetCurrent''は、その同一の実行ループを返します。
  
-     */+例として、以下の<html><ruby><rb>コード片</rb><rp>(</rp><rt>snippet</rt><rp>)</rp></ruby></html>はストリーム??stream??を現在のスレッドの(まだ実行していない)実行ループにスケジュールする方法を示します:
  
-    CFStringRef mypath = CFSTR("/path/to/scan");+<code c> 
 +FSEventStreamRef stream; 
 +/* 以下の関数を呼ぶ前にストリームを生成する。 */ 
 +FSEventStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(),         kCFRunLoopDefaultMode); 
 +</code>
  
-    CFArrayRef pathsToWatch = CFArrayCreate(NULL, (const void **)&mypath, 1, NULL);+イベントストリーム設定の最終工程は''FSEventStreamStart''を呼ぶことです。 
 +この関数は、イベントストリームにイベントの送信開始を指示します。 
 +開始させるイベントストリームが唯一の引数です。
  
-    void *callbackInfo = NULL; // could put stream-specific data here.+イベントストリームの生成とスケジュールを行い、もしまだ実行ループを走らせていなければ、''CFRunLoopRun''を読んでそれを始動させましょう。
  
-    FSEventStreamRef stream;+===== イベントの取り扱い =====
  
-    CFAbsoluteTime latency = 3.0; /* Latency in seconds */+イベントハンドラーコールバックは''FSEventStreamCallback''プロトタイプに適合していなければなりません。 
 +パラメータは''FSEventStreamCallback''データ型のリファレンスマニュアルで解説しています。
  
- +イベントハンドラは、パス、識別子、フラグの3つのリストを受け取ります。 
 +実質的に、これらがイベントのリストを表します。 
 +The first event consists of the first entry taken from each of the arrays, and so on. 
 +イベント処理の必要に応じて、ハンドラはこれらリストをイテレートして下さい。
  
-    /* Create the streampassing in a callback */+For each event, you should scan the directory at the specified pathprocessing its contents as desired. 
 +通常、そのパスによって示されるディレクトリだけを走査する必要があります。しかしながら、そのケースに当てはまらない3つの状況があります:
  
-    stream = FSEventStreamCreate(NULL, +  1つのディレクトリにおいて、サブディレクトリ内で複数のイベントが同時に発生した場合、それらイベントは1つのイベントにまとめられる可能性があります。このケースでは、''kFSEventStreamEventFlagMustScanSubDirs''フラグが立ったイベントを受信することになります。このようなイベントを受信した時は、そのイベントに載っているパスを再帰的に再走査すべきです。変化の追加分は、必ずしもリストアップされたパスの直接の子供にあるとは限りません。 
- +  カーネルとユーザー空間の間でコミュニケーションエラーが発生した場合、''kFSEventStreamEventFlagKernelDropped''か''kFSEventStreamEventFlagUserDropped''フラグが立ったイベントを受け取ることになるでしょう。このケースでは、監視中の全てのディレクトリをフルスキャンしなければなりません。なぜならば、何が変更されたかを決める一切の手立てがないからです。
-        &myCallbackFunction, +
- +
-        callbackInfo, +
- +
-        pathsToWatch, +
- +
-        kFSEventStreamEventIdSinceNow, /Or a previous event ID */ +
- +
-        latency, +
- +
-        kFSEventStreamCreateFlagNone /Flags explained in reference */ +
- +
-    ); +
- +
-Once you have created an event stream, you must schedule it on your application’s run loop. To do this, call FSEventStreamScheduleWithRunLoop, passing in the newly-created stream, a reference to your run loop, and a run loop mode. For more information about run loops, read Run Loops. +
- +
-If you don’t already have a run loop, you will need to devote a thread to this task. After creating a thread using your API of choice, call CFRunLoopGetCurrent to allocate an initial run loop for that thread. Any future calls to CFRunLoopGetCurrent will return the same run loop. +
- +
-For example, the following snippet shows how to schedule a stream, called stream, on the current thread’s run loop (not yet running): +
- +
-    FSEventStreamRef stream; +
- +
-    /* Create the stream before calling this. */ +
- +
-    FSEventStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(),         kCFRunLoopDefaultMode); +
- +
-The final step in setting up an event stream is to call FSEventStreamStart. This function tells the event stream to begin sending events. Its sole parameter is the event stream to start. +
- +
-Once the event stream has been created and scheduled, if your run loop is not already running, you should start it by calling CFRunLoopRun. +
-Handling Events +
- +
-Your event handler callback must conform to the prototype for FSEventStreamCallback. The parameters are described in the reference documentation for the FSEventStreamCallback data type. +
- +
-Your event handler receives three lists: a list of paths, a list of identifiers, and a list of flags. In effect, these represent a list of events. The first event consists of the first entry taken from each of the arrays, and so on. Your handler must iterate through these lists, processing the events as needed. +
- +
-For each event, you should scan the directory at the specified path, processing its contents as desired. Normally, you need to scan only the exact directory specified by the path. However, there are three situations in which this is not the case: +
- +
-    If an event in a directory occurs at about the same time as one or more events in a subdirectory of that directory, the events may be coalesced into a single event. In this case, you will receive an event with the kFSEventStreamEventFlagMustScanSubDirs flag set. When you receive such an event, you must recursively rescan the path listed in the event. The additional changes are not necessarily in an immediate child of the listed path. +
- +
-    If a communication error occurs between the kernel and the user-space daemon, you may receive an event with either the kFSEventStreamEventFlagKernelDropped or kFSEventStreamEventFlagUserDropped flag set. In either case, you must do a full scan of any directories that you are monitoring because there is no way to determine what may have changed.+
  
 +<note>
 +イベントのドロップ時は''kFSEventStreamEventFlagMustScanSubDirs''フラグも同様にセットされます。
 +上で述べたように、パスのフルスキャンを行うべきかどうかの判断では、
     Note: When an event is dropped, the kFSEventStreamEventFlagMustScanSubDirs flag is also set. Thus, it is not necessary to explicitly check for the dropped event flags when determining whether to perform a full rescan of a path. The dropped event flags are provided purely for informational purposes.     Note: When an event is dropped, the kFSEventStreamEventFlagMustScanSubDirs flag is also set. Thus, it is not necessary to explicitly check for the dropped event flags when determining whether to perform a full rescan of a path. The dropped event flags are provided purely for informational purposes.
  
  • translation/working/翻訳5.1461759682.txt.gz
  • 最終更新: 2016-04-27 21:21
  • by Decomo