public override NT_STATUS GetAttributes(UserContext UserContext, FileContext FileObject, out DirectoryContext data) { //FIXME: attributes? what attributes? //Should be implemented very fast, is called quit often data = new DirectoryContext(); string FileName = root + FileObject.Name; DateTime dd = new DateTime(2007, 1, 1); if (phone.Exists(FileName) && !phone.IsDirectory(FileName)) { data.Attrib = FileAttributes.Normal; data.CreationTime = dd; data.LastAccessTime = dd; data.LastWriteTime = dd; data.FileSize = (long)phone.FileSize(FileName); // data.AllocationSize willbe set to the same value data.Name = FileObject.Name; data.ShortName = ""; //GetShortName(FileObject.Name); return(NT_STATUS.OK); } if (phone.Exists(FileName) && phone.IsDirectory(FileName)) { data.Attrib = FileAttributes.Directory; data.CreationTime = dd; data.LastAccessTime = dd; data.LastWriteTime = dd; data.FileSize = (long)phone.FileSize(FileName); data.Name = FileObject.Name; data.ShortName = "";//GetShortName(FileName); return(NT_STATUS.OK); } // Now we know that the object is not there, let's see if the path (=UpperDir) is valid if (!Directory.Exists(root + Path.GetDirectoryName(FileObject.Name))) { return(NT_STATUS.OBJECT_PATH_NOT_FOUND); } return(NT_STATUS.OBJECT_NAME_NOT_FOUND); }
private Byte[] GetHeaderBytes(String fileName, Int32 offset, Int32 length) { Byte[] retval = null; using (Stream fileStream = iPhoneFile.OpenRead(phone, fileName)) { Byte[] buffer = new Byte[length]; Int32 bytesRead; if ((offset + length) <= phone.FileSize(fileName)) { bytesRead = fileStream.Read(buffer, offset, length); retval = buffer; } } return(retval); }
private Byte[] ReadFile(String inFile, Int32 length) { Int32 bufferSize = myPhone.FileSize(inFile); Int32 maxBytes = 0; if (length == -1) { maxBytes = bufferSize; } else { maxBytes = Math.Min(length, bufferSize); } Byte[] fileBuffer = new Byte[maxBytes]; using (Stream inStream = iPhoneFile.OpenRead(myPhone, inFile)) { bufferSize = inStream.Read(fileBuffer, 0, fileBuffer.Length); } return(fileBuffer); }