public static IJournal <T> CreateJournal <T>(JournalElement config, EFileAccess access = EFileAccess.Read) { return(new JournalBuilder(config ?? ReadConfig <T>()) .WithAccess(access) .WithSerializerFactoryName(MetadataConstants.THRIFT_SERIALIZER_NAME) .ToJournal <T>()); }
public static IJournalCore CreateJournal(string path, EFileAccess access = EFileAccess.Read) { return(new JournalBuilder() .WithAccess(access) .WithLocation(path) .ToJournal()); }
public static IJournal <T> CreateJournal <T>(EFileAccess access = EFileAccess.Read, string subdir = null) { return(new JournalBuilder(ReadConfig <T>()) .WithSerializerFactoryName(MetadataConstants.THRIFT_SERIALIZER_NAME) .WithAccess(access) .ToJournal <T>()); }
internal static extern SafeFileHandle CreateFile(string lpFileName, EFileAccess dwDesiredAccess, EFileShare dwShareMode, IntPtr lpSecurityAttributes, ECreationDisposition dwCreationDisposition, EFileAttributes dwFlagsAndAttributes, IntPtr hTemplateFile);
public CompositeRawFile(string fileName, int bitHint, ICompositeFileFactory mmf, EFileAccess access, int partitionID, int fileID, int columnID, EDataType dataType, int minBitHint) { if (bitHint < minBitHint || bitHint > MetadataConstants.MAX_FILE_BIT_HINT) { throw new NFSdbConfigurationException("Calclated size of file {0} " + "is invalid. Should be >= 2^{1} and <= 2^{2} " + "but was 2^{3}", fileName, MetadataConstants.MIN_FILE_BIT_HINT, MetadataConstants.MAX_FILE_BIT_HINT, bitHint); } _bitHint = bitHint; Access = access; _compositeFile = mmf.OpenFile(fileName, bitHint, access); PartitionID = partitionID; FileID = fileID; ColumnID = columnID; DataType = dataType; Filename = fileName; _pointersArray = LongAllocate(INITIAL_PARTS_COLLECTION_SIZE); _pointersArrayLen = INITIAL_PARTS_COLLECTION_SIZE; _pointersArrayFixedLen = INITIAL_PARTS_COLLECTION_SIZE; }
internal static extern System.IntPtr CreateFile(string lpFileName, [MarshalAs(UnmanagedType.U4)] EFileAccess dwDesiredAccess, [MarshalAs(UnmanagedType.U4)] EFileShare dwShareMode, System.IntPtr lpSecurityAttributes, [MarshalAs(UnmanagedType.U4)] ECreationDisposition dwCreationDisposition, [MarshalAs(UnmanagedType.U4)] uint dwFlagsAndAttributes, System.IntPtr hTemplateFile);
public static PartitionData <T> CreatePartition <T>(int?recordHint = null, EFileAccess access = EFileAccess.Read, EFileFlags fileFlags = EFileFlags.None) { var mmFactory = new CompositeFileFactory(fileFlags); using (var dbXml = typeof(Quote).Assembly.GetManifestResourceStream( "Apaf.NFSdb.TestShared.Resources.nfsdb.xml")) { var dbElement = ConfigurationSerializer.ReadConfiguration(dbXml); var jconf = dbElement.Journals.Single(j => j.Class.EndsWith("." + typeof(T).Name)); if (recordHint.HasValue) { jconf.RecordHint = recordHint.Value; } var journalPath = Path.Combine(FindJournalsPath(), jconf.DefaultPath); jconf.DefaultPath = journalPath; var metadata = JournalBuilder.CreateNewJournalMetadata(jconf); var startDate = new DateTime(2013, 10, 1); var journalStorage = new ColumnStorage(metadata, jconf.DefaultPath, access, 0, mmFactory); var part = new Partition( metadata, new CompositeFileFactory(fileFlags), access, new PartitionDate(startDate, 0, metadata.Settings.PartitionType), 0, Path.Combine(jconf.DefaultPath, "2013-10"), new AsyncJournalServer(TimeSpan.FromSeconds(1))); return(new PartitionData <T>(part, metadata, journalStorage, journalPath)); } }
private static SafeFileHandle OpenReparsePoint(string reparsePoint, EFileAccess accessMode) { SafeFileHandle reparsePointHandle = null; // Retry a few times in case the folder has just been created and a file in use by another process error occurs for (var folderOpenAttempts = 0; folderOpenAttempts < 5; folderOpenAttempts++) { if (folderOpenAttempts != 0) { Thread.Sleep(25); } reparsePointHandle = new SafeFileHandle(CreateFile(reparsePoint, accessMode, EFileShare.Read | EFileShare.Write | EFileShare.Delete, IntPtr.Zero, ECreationDisposition.OpenExisting, EFileAttributes.BackupSemantics | EFileAttributes.OpenReparsePoint, IntPtr.Zero), ownsHandle: true); if (Marshal.GetLastWin32Error() == 0) { break; //Success } } if (Marshal.GetLastWin32Error() != 0) { ThrowLastWin32Error("Unable to open reparse point."); } return(reparsePointHandle); }
private IRawFile CreateCompFile(int chunkSize, EFileAccess readWrite) { var bitHint = (int)Math.Ceiling(Math.Log(chunkSize, 2)); return(new CompositeRawFile(_dummyFileName, bitHint, new CompositeFileFactory(), readWrite, 0, 0, 0, EDataType.Data, 1)); }
private static SafeFileHandle OpenReparsePoint(string reparsePoint, EFileAccess accessMode) { SafeFileHandle reparsePointHandle = null; try { IntPtr createFileResult = CreateFile( reparsePoint, accessMode, EFileShare.Read | EFileShare.Write | EFileShare.Delete, IntPtr.Zero, ECreationDisposition.OpenExisting, EFileAttributes.BackupSemantics | EFileAttributes.OpenReparsePoint, IntPtr.Zero); if (Marshal.GetLastWin32Error() != 0) { ThrowLastWin32Error("Unable to open reparse point."); } reparsePointHandle = new SafeFileHandle(createFileResult, true); return(reparsePointHandle); } catch { if (reparsePointHandle != null) { reparsePointHandle.Dispose(); } throw; } }
private static SafeFileHandle OpenExistingFile(string devicePath, EFileAccess fileAccess) { return(Kernel32.CreateFile( devicePath, fileAccess, EFileShare.Read | EFileShare.Write, IntPtr.Zero, ECreationDisposition.OpenExisting, EFileAttributes.None, IntPtr.Zero)); }
public static IntPtr CreateFileFromDevice(string filename, EFileAccess desiredAccess, EFileShare shareMode) { return(CreateFile(filename, desiredAccess, shareMode, IntPtr.Zero, ECreationDisposition.OpenExisting, EFileAttributes.Device | EFileAttributes.Overlapped, IntPtr.Zero)); }
internal static extern Microsoft.Win32.SafeHandles.SafeFileHandle CreateFile( string fileName, [MarshalAs(UnmanagedType.U4)] EFileAccess fileAccess, [MarshalAs(UnmanagedType.U4)] System.IO.FileShare fileShare, IntPtr securityAttributes, [MarshalAs(UnmanagedType.U4)] System.IO.FileMode creationDisposition, [MarshalAs(UnmanagedType.U4)] System.IO.FileAttributes flags, IntPtr template);
public static extern SafeFileHandle CreateFile( [In][MarshalAs(UnmanagedType.LPWStr)] string filename, [In][MarshalAs(UnmanagedType.U4)] EFileAccess dwDesiredAccess, [In][MarshalAs(UnmanagedType.U4)] EFileShare dwShareMode, [In, Optional] IntPtr lpSecurityAttributes, [In][MarshalAs(UnmanagedType.U4)] ECreationDisposition dwCreationDisposition, [In][MarshalAs(UnmanagedType.U4)] EFileAttributes dwFlagsAndAttributes, [In, Optional] IntPtr hTemplateFile);
public static extern SafeFileHandle CreateFile( /* [in] */ [MarshalAs(UnmanagedType.LPWStr)] string fileName, /* [in] */ [MarshalAs(UnmanagedType.U4)] EFileAccess desiredAccess, /* [in] */ [MarshalAs(UnmanagedType.U4)] FileShare shareMode, /* [in] */ IntPtr securityAttributes, /* [in] */ [MarshalAs(UnmanagedType.U4)] FileMode createMode, /* [in] */ [MarshalAs(UnmanagedType.U4)] EFileAttributes flagsAndAttributes, /* [in] */ IntPtr templateFile);
private static extern IntPtr CreateFile( string fileName, EFileAccess fileAccess, EFileShare fileShare, IntPtr securityAttributes, ECreationDisposition creationDisposition, EFileAttributes flags, IntPtr template);
internal static extern SafeFileHandle CreateFile( string fileName, [MarshalAs(UnmanagedType.U4)] EFileAccess fileAccess, [MarshalAs(UnmanagedType.U4)] EFileShare shareMode, IntPtr securityAttributes, [MarshalAs(UnmanagedType.U4)] ECreationDisposition creationDisposition, EFileAttributes flagsAndAttributes, SafeFileHandle templateFile);
internal static extern SafeFileHandle CreateFile( string fileName, EFileAccess desiredAccess, uint shareMode, IntPtr securityAttributes, uint creationDisposition, uint flagsAndAttributes, IntPtr templateFile);
internal static extern SafeFileHandle CreateFile( string lpFileName, EFileAccess dwDesiredAccess, uint dwShareMode, IntPtr lpSecurityAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile);
public static extern IntPtr CreateFile( [MarshalAs(UnmanagedType.LPTStr)] string filename, [MarshalAs(UnmanagedType.U4)] EFileAccess access, [MarshalAs(UnmanagedType.U4)] EFileShare share, IntPtr securityAttributes, // optional SECURITY_ATTRIBUTES struct or IntPtr.Zero [MarshalAs(UnmanagedType.U4)] ECreationDisposition creationDisposition, [MarshalAs(UnmanagedType.U4)] EFileAttributes flagsAndAttributes, IntPtr templateFile);
public static extern SafeFileHandle CreateFile( [MarshalAs(UnmanagedType.LPTStr)] string lpFileName, [MarshalAs(UnmanagedType.U4)] EFileAccess dwDesiredAccess, [MarshalAs(UnmanagedType.U4)] EFileShare dwShareMode, IntPtr lpSecurityAttributes, // optional SECURITY_ATTRIBUTES struct or IntPtr.Zero [MarshalAs(UnmanagedType.U4)] ECreationDisposition dwCreationDisposition, [MarshalAs(UnmanagedType.U4)] EFileAttributes dwFlagsAndAttributes, IntPtr hTemplateFile);
public static extern SafeFileHandle CreateFileW( [MarshalAs(UnmanagedType.LPWStr)] string filename, EFileAccess access, [MarshalAs(UnmanagedType.U4)] FileShare share, IntPtr securityAttributes, [MarshalAs(UnmanagedType.U4)] FileMode creationDisposition, [MarshalAs(UnmanagedType.U4)] FileAttributes flagsAndAttributes, IntPtr templateFile);
public static extern IntPtr CreateFile( [MarshalAs(UnmanagedType.LPTStr)] string filename, [MarshalAs(UnmanagedType.U4)] EFileAccess access, [MarshalAs(UnmanagedType.U4)] EFileShare share, IntPtr securityAttributes, [MarshalAs(UnmanagedType.U4)] ECreationDisposition creationDisposition, [MarshalAs(UnmanagedType.U4)] EFileAttributes flagsAndAttributes, IntPtr templateFile);
public static extern SafeFileHandle CreateFile( string fileName, EFileAccess fileAccess, [MarshalAs(UnmanagedType.U4)] FileShare fileShare, IntPtr securityAttributes, [MarshalAs(UnmanagedType.U4)] FileMode creationDisposition, int flags, IntPtr template);
private static extern IntPtr CreateFile( [MarshalAs(UnmanagedType.LPTStr)] string lpFileName, [MarshalAs(UnmanagedType.U4)] EFileAccess dwDesiredAccess, [MarshalAs(UnmanagedType.U4)] EFileShare dwShareMode, [MarshalAs(UnmanagedType.SysInt)] IntPtr lpSecurityAttributes, [MarshalAs(UnmanagedType.U4)] ECreationDisposition dwCreationDisposition, [MarshalAs(UnmanagedType.U4)] EFileAttributes dwFlagsAndAttributes, [MarshalAs(UnmanagedType.U4)] uint hTemplateFile);
private static extern IntPtr CreateFile( String lpFileName, EFileAccess dwDesiredAccess, EFileShare dwShareMode, IntPtr lpSecurityAttributes, ECreationDisposition dwCreationDisposition, EFileAttributes dwFlagsAndAttributes, IntPtr hTemplateFile);
private static extern IntPtr CreateFile( string lpFileName, EFileAccess dwDesiredAccess, EFileShare dwShareMode, IntPtr lpSecurityAttributes, ECreationDisposition dwCreationDisposition, EFileAttributes dwFlagsAndAttributes, IntPtr hTemplateFile);
public static extern SafeFileHandle CreateFile( string lpFileName, EFileAccess dwDesiredAccess, EFileShare dwShareMode, IntPtr SecurityAttributes, ECreationDisposition dwCreationDisposition, EFileAttributes dwFlagsAndAttributes, IntPtr hTemplateFile );
static SafeFileHandle open(string filePath, string streamName, EFileAccess access, ECreationDisposition mode) { var sfh = CreateFile($"{filePath}:{streamName}", access, EFileShare.Read, IntPtr.Zero, mode, EFileAttributes.Normal, IntPtr.Zero); if (sfh.IsInvalid) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } return(sfh); }
private static IJournal <Journal> OpenJournal(EFileAccess access) { string directoryPath = Path.Combine(Utils.FindJournalsPath(), FOLDER_PATH); return(new JournalBuilder() .WithRecordCountHint(GENERATE_RECORDS_COUNT_PER_PARTITION) .WithPartitionBy(EPartitionType.Month) .WithLocation(directoryPath) .WithTimestampColumn("Timestamp") .WithAccess(access) .ToJournal <Journal>()); }
private static IJournal <File> OpenJournal(EFileAccess access) { string directoryPath = Path.Combine(Utils.FindJournalsPath(), FolderPath); return(new JournalBuilder() .WithRecordCountHint(TestUtils.GENERATE_RECORDS_COUNT) .WithPartitionBy(EPartitionType.Month) .WithLocation(directoryPath) .WithSymbolColumn("Path", 10000, 20, 20) .WithTimestampColumn("Timestamp") .WithAccess(access) .ToJournal <File>()); }
public MemoryFile(string fileName, int bitHint, EFileAccess access, EFileFlags fileFlags) { if (fileName == null) { throw new ArgumentNullException("fileName"); } Filename = fileName; _bitHint = bitHint; _access = access; _fileFlags = fileFlags; _fullName = Path.GetFullPath(fileName); }
public ColumnStorage( IJournalMetadata metadata, string folder, EFileAccess access, int partitionID, ICompositeFileFactory compositeFileFactory) { _access = access; _partitionID = partitionID; _compositeFileFactory = compositeFileFactory; _folder = folder; _openedFiles = new IRawFile[metadata.FileCount]; }
public static extern IntPtr CreateFile(string filename, EFileAccess desiredAccess, EFileShare shareMode, IntPtr securityAttributes, ECreationDisposition creationDisposition, EFileAttributes attributes, IntPtr template);
public static IntPtr CreateFileFromDevice(string filename, EFileAccess desiredAccess, EFileShare shareMode) { return CreateFile(filename, desiredAccess, shareMode, IntPtr.Zero, ECreationDisposition.OpenExisting, EFileAttributes.Device | EFileAttributes.Overlapped, IntPtr.Zero); }
private static SafeFileHandle OpenExistingFile(string devicePath, EFileAccess fileAccess) { return Kernel32.CreateFile( devicePath, fileAccess, EFileShare.Read | EFileShare.Write, IntPtr.Zero, ECreationDisposition.OpenExisting, EFileAttributes.None, IntPtr.Zero); }
private SafeFileHandle OpenReparsePoint(string reparsePoint, EFileAccess accessMode) { var reparsePointHandle = new SafeFileHandle(CreateFile(reparsePoint, accessMode, EFileShare.Read | EFileShare.Write | EFileShare.Delete, IntPtr.Zero, ECreationDisposition.OpenExisting, EFileAttributes.BackupSemantics | EFileAttributes.OpenReparsePoint, IntPtr.Zero), true); if (Marshal.GetLastWin32Error() != 0) ThrowLastWin32Error("Unable to open reparse point."); return reparsePointHandle; }
private static extern IntPtr CreateFile(string fileName, EFileAccess desiredAccess, EFileShare shareMode, IntPtr securityAttributes, ECreationDisposition creationDisposition, EFileAttributes flagsAndAttributes, IntPtr templateFile);
/// <summary> /// Opens a reparse point. /// </summary> /// <param name="reparsePoint">The reparse point to open.</param> /// <param name="accessMode">Access mode use to open the reparse point.</param> /// <returns>A safe file handle.</returns> private static SafeFileHandle OpenReparsePoint(string reparsePoint, EFileAccess accessMode) { SafeFileHandle reparsePointHandle = null; try { IntPtr createFileResult = CreateFile( reparsePoint, accessMode, EFileShare.Read | EFileShare.Write | EFileShare.Delete, IntPtr.Zero, ECreationDisposition.OpenExisting, EFileAttributes.BackupSemantics | EFileAttributes.OpenReparsePoint, IntPtr.Zero); if (Marshal.GetLastWin32Error() != 0) { ThrowLastWin32Error(Strings.UnableToOpenReparsePoint); } reparsePointHandle = new SafeFileHandle(createFileResult, true); return reparsePointHandle; } catch { if (reparsePointHandle != null) { reparsePointHandle.Dispose(); } throw; } }
internal static extern SafeFileHandle CreateFileW( string lpFileName, EFileAccess dwDesiredAccess, EFileShare dwShareMode, SECURITY_ATTRIBUTES lpSecurityAttributes, ECreationDisposition dwCreationDisposition, EFileAttributes dwFlagsAndAttributes, IntPtr hTemplateFile);
public static IntPtr _CreateFile( string lpFileName, EFileAccess dwDesiredAccess, EFileShare dwShareMode, ECreationDisposition dwCreationDisposition, EFileAttributes dwFlagsAndAttributes, IntPtr hTemplateFile ) { SECURITY_DESCRIPTOR sd = new SECURITY_DESCRIPTOR(); InitializeSecurityDescriptor(ref sd, SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorDacl(ref sd, true, IntPtr.Zero, false); GCHandle sdHandle = GCHandle.Alloc(sd, GCHandleType.Pinned); SECURITY_ATTRIBUTES sa = new SECURITY_ATTRIBUTES(); sa.nLength = Marshal.SizeOf(sa); sa.lpSecurityDescriptor = sdHandle.AddrOfPinnedObject(); sa.bInheritHandle = 0; GCHandle saHandle = GCHandle.Alloc(sa, GCHandleType.Pinned); System.IntPtr hFile = IntPtr.Zero; hFile = CreateFile( lpFileName, dwDesiredAccess, dwShareMode, saHandle.AddrOfPinnedObject(), dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile ); saHandle.Free(); sdHandle.Free(); if (hFile == (System.IntPtr)(int)-1) { return IntPtr.Zero; } return hFile; }