// Open a single file, list the file attributes, and close the file. // Returns null if the file doesn't exist or is a directory. private IFSListAttrsRep listObjAttrs(int attrsType, int flags1, int flags2) throws IOException, AS400SecurityException { // Assume connect() has already been done. IFSListAttrsRep reply = null; int fileHandle = UNINITIALIZED; // Design note: In order to get an OA* structure back in the "List File Attributes" reply, we // must specify the file by handle rather than by name. boolean usedGlobalHandle = false; // @KKBA try { // Open the file, and obtain a file handle. if (fileHandle_ != UNINITIALIZED) // @KKBA { // @KKBA fileHandle = fileHandle_; // @KKBA usedGlobalHandle = true; // @KKBA } // @KKBA else { fileHandle = createFileHandle(); // @KKBC if (fileHandle == UNINITIALIZED) { if (Trace.traceOn_) Trace.log( Trace.ERROR, "Unable to create handle to file " + path_ + ". IFSReturnCodeRep return code", errorRC_); return null; } } // Send a 'list attributes' request, specifying the file handle we just created, // and indicating that we want an OA2 structure in the reply. IFSListAttrsReq req1 = new IFSListAttrsReq(fileHandle, attrsType, flags1, flags2); req1.setPatternMatching(patternMatching_); Vector replys = listAttributes(req1); // Verify that we got exactly one reply. if (replys == null) { if (Trace.traceOn_) Trace.log(Trace.WARNING, "Received null from listAttributes(fileHandle)."); } else if (replys.size() == 0) { if (Trace.traceOn_) Trace.log(Trace.WARNING, "Received no replies from listAttributes(fileHandle)."); } else if (replys.size() > 1) { if (Trace.traceOn_) Trace.log( Trace.WARNING, "Received multiple replies from listAttributes(fileHandle) (" + replys.size() + ")"); } else { reply = (IFSListAttrsRep) replys.elementAt(0); } } finally { if (!usedGlobalHandle && fileHandle != UNINITIALIZED) // @KKBA close(fileHandle); } return reply; }